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

[EuiDataGrid] Account for horizontal scrollbar when determining height #5478

Merged

Conversation

chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Dec 15, 2021

Summary

When computing the unconstrained height, now determine if a horizontal scroll is present & find its height, adding that to the datagrid contents' height. This helps address (and may close) some open issues like #4848 , but there's been a lot of movement and re-validating these issues will be necessary before closing them.

To test: in the primary data grid example, resize any of the columns so you get a horizontal scrollbar. Previously, the vertical scrollbar would be present to scroll the extra 13 pixels. Now, all the cells + horizontal scroll are rendered and no vertical scrolling is needed.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes

  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
    - [ ] Props have proper autodocs and playground toggles
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@cee-chen
Copy link
Contributor

It looks like part of #5475 was left in this PR, you may want to rebase against main and force-push

@chandlerprall chandlerprall force-pushed the bug/4848-horizontal-scroll-bar branch from 12e8c3f to 3230f05 Compare December 15, 2021 22:44
@chandlerprall
Copy link
Contributor Author

It looks like part of #5475 was left in this PR, you may want to rebase against main and force-push

I tried to be all fancy with branches and failed. But having the hot reload helped testing a lot! :)

Resolved && force-pushed

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5478/

@cee-chen
Copy link
Contributor

cee-chen commented Dec 16, 2021

Tested on Chrome, Safari, Edge, and Firefox (finally figured out what was going on with my local Firefox instance - I have layout.css.devPixelsPerPx set to an approx 125% increase to make my GUI larger/easier to read, which is apparently throwing off datagrid's calculations - but I can switch to a separate Firefox profile to test) and this LGTM.

We should def test #4848 and #5131 on Kibana after release/upgrade - I tested fullscreen mode as well and can confirm the horizontal scrollbar works there (although it looks like it's also already working on prod, so maybe I'm not reading the issue correctly?)

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work on this, the code is super clean/easy to follow & understand!

@@ -50,6 +50,7 @@ import {
} from '../data_grid_types';
import { makeRowManager } from './data_grid_row_manager';
import { useForceRender } from '../../../services/hooks/useForceRender';
import { useUpdateEffect } from '../../../services';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, glad this is already coming in handy! 🎉

Comment on lines +323 to +327
// https://stackoverflow.com/a/5038256
const hasHorizontalScroll =
(outerGridRef.current?.scrollWidth ?? 0) >
(outerGridRef.current?.clientWidth ?? 0);
// https://stackoverflow.com/a/24797425
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I appreciate the extra context / honesty of adding stack overflow links 😆

Comment on lines +665 to +666
const outerGridRef = useRef<HTMLDivElement | null>(null); // container that becomes scrollable
const innerGridRef = useRef<HTMLDivElement | null>(null); // container sized to fit all content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also appreciate this extra comment context + reorganization

@chandlerprall
Copy link
Contributor Author

(although it looks like it's also already working on prod, so maybe I'm not reading the issue correctly?)

I agree, that does appear to be already fixed.

@cee-chen
Copy link
Contributor

jenkins test this

chandlerprall and others added 2 commits December 16, 2021 14:42
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5478/

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cypress changes LGTM! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants