Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dashboards bar does not resize to 1 row [DHIS2-11097] #1761

Merged
merged 9 commits into from
May 11, 2021
7 changes: 4 additions & 3 deletions src/pages/view/DashboardsBar/DashboardsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ const DashboardsBar = ({
onExpandedChanged,
}) => {
const [dragging, setDragging] = useState(false)
const [mouseYPos, setMouseYPos] = useState(0)
const userRowsChanged = useRef(false)
const ref = createRef()
const { height } = useWindowDimensions()

const rootElement = document.documentElement

const adjustRows = mouseYPos => {
useEffect(() => {
const newRows = Math.max(
MIN_ROW_COUNT,
getRowsFromHeight(mouseYPos - 52) // don't rush the transition to a bigger row count
Expand All @@ -44,7 +45,7 @@ const DashboardsBar = ({
updateUserRows(Math.min(newRows, MAX_ROW_COUNT))
userRowsChanged.current = true
}
}
}, [mouseYPos])

useEffect(() => {
rootElement.style.setProperty('--user-rows-count', userRows)
Expand Down Expand Up @@ -102,7 +103,7 @@ const DashboardsBar = ({
/>
<DragHandle
setDragging={setDragging}
onHeightChanged={adjustRows}
onHeightChanged={setMouseYPos}
/>
</div>
<div className={cx(classes.spacer)} />
Expand Down