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] [v36] #1762

Merged
merged 3 commits into from
May 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/ControlBar/ViewControlBar/DashboardsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ const DashboardsBar = ({
}) => {
const [dragging, setDragging] = useState(false)
const userRowsChanged = useRef(false)
const [mouseYPos, setMouseYPos] = useState(0)
const ref = createRef()
const { height } = useWindowDimensions()

const rootElement = document.documentElement

const adjustRows = newHeight => {
useEffect(() => {
const newRows = Math.max(
MIN_ROW_COUNT,
getRowsFromHeight(newHeight - 52) // don't rush the transition to a bigger row count
getRowsFromHeight(mouseYPos - 52) // don't rush the transition to a bigger row count
)

if (newRows !== userRows) {
updateUserRows(Math.min(newRows, MAX_ROW_COUNT))
userRowsChanged.current = true
}
}
}, [mouseYPos])

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