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

Overhaul EuiDataGrid's cell focus states #3128

Merged

Conversation

chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Mar 19, 2020

Summary

Fixes #2626

This is ready to review functionality, not yet the code side.

Added a new docs page for data grid, Data grid focus, to track requirements and provide a datagrid for testing these states. This also touched EuiFocusTrap's outside-click-disabling, so we'll want to double check that (added ability to re-enable a trap which was previously-disabled-by-click).

I also want to diagram/record the focus logic and refactor it, but that has to wait until the logic is solidified and should be in another PR.

Checklist

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

  • Checked in mobile
  • Checked in IE11 and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation examples
  • Added or updated jest 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

@kibanamachine
Copy link

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

@myasonik
Copy link
Contributor

myasonik commented Mar 19, 2020

When tabbing into the grid for the first time, focus skips all the toolbar items.

Full steps

  1. Start tabbing at the top of the page (tab through "demo", "demo js", and "demo html"

The bug

Tabbing from "demo html" goes directly to the first cell instead of the first toolbar item

Note: Only tested in Firefox

@myasonik
Copy link
Contributor

OK, I've got a very odd bug...

Full steps

  1. Load page
  2. Use mouse to adjust column width
  3. Click off the data grid
  4. Start tabbing (tab through "demo", "demo js", keep tabbing through all of the toolbar controls)

THE BUG

After the last toolbar control but before the first cell, notice an extra tab stop where focus is seems to be set on the whole grid

Note: Only tested in Firefox

@myasonik
Copy link
Contributor

A feature request for the test page (which I otherwise love!) — a toggle on the page to make the columns interactive

@chandlerprall
Copy link
Contributor Author

When tabbing into the grid for the first time, focus skips all the toolbar items.

Fixed, was targeting the wrong div

After the last toolbar control but before the first cell, notice an extra tab stop where focus is seems to be set on the whole grid

FireFox allows tabbing to a scrollable element. I've added an explicit tabindex=-1 to disable that.

A feature request for the test page (which I otherwise love!) — a toggle on the page to make the columns interactive

Not sure I know exactly what you mean; I take this to mean having 3 columns with no interactive elements and the toggle show/hides interactive elements into those?

@kibanamachine
Copy link

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

@myasonik
Copy link
Contributor

Confirmed that I can't recreate those bugs anymore! 🎉

Don't know if this is something you want to handle here or as part of another ticket (as it's not introduced as part of this PR):
If a cell is partially cut off by the scrolling container, there's no way to see the whole thing with just a keyboard. If the cell is completely cut off, the browser will scroll it into view for you.

We should scroll the container to completely show the currently focused cell.

@chandlerprall
Copy link
Contributor Author

If a cell is partially cut off by the scrolling container, there's no way to see the whole thing with just a keyboard. If the cell is completely cut off, the browser will scroll it into view for you.

I noticed this when testing in FF yesterday (Chrome works as expected). Let's deal with that in another issue. Mind creating it?

@chandlerprall
Copy link
Contributor Author

Pushed a toggle to enable/disable interactive headers in the focus example, which caught another focus bug.

@kibanamachine
Copy link

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

@myasonik
Copy link
Contributor

Not 100% sure what the interaction here should be so just bringing this up for discussion

Steps

  1. Arrow over to a cell with 1 interactive item that is not expandable.
  2. tab out and back into the grid

Bug?

Focus is set on the cell, not on the content as it is when arrowing around in the grid.

(You can also recreate this effect by clicking in the cell but not on the interactive item itself.)

@myasonik
Copy link
Contributor

Advanced keyboard control bugs

  • Using F2 should be the same as using Enter when the cell is not expanded (this works as expected) and the same as Esc when it is expanded (this does not work)
  • Page Up and Page Down seems to have broken (should set focus to the first/last row in the same column you're currently in

@snide
Copy link
Contributor

snide commented Mar 24, 2020

I'm doing a cleanup pass on the docs for this as part of my review. Functionally it seems to make sense. Issues that I see in it such as how to tab through truncated items I think are solvable by judicious use of other bits of functionality in Data Grid such as set widths, expandable cells...etc.

@kibanamachine
Copy link

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

@snide
Copy link
Contributor

snide commented Apr 2, 2020

Sorry, the commit reminded me I still have a todo here. I'll try and get it done this week. I didn't see any major issues functionally. If @myasonik is OK with the state of this PR, I can always PR after since my changes were just to docs.

@kibanamachine
Copy link

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

@chandlerprall
Copy link
Contributor Author

@myasonik all 3 bugs are now fixed!

@kibanamachine
Copy link

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

@chandlerprall
Copy link
Contributor Author

After iterating with @myasonik , page up & page down will now always shift focus to the bottom or top (respectively) of the page, not only when actually paging. Also added pagination to the focus example for easier testing.

@kibanamachine
Copy link

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

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

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

After playing around with it, I think this is better than what we had for sure.

I wonder if I might still expect that if you're on the first/last page that page up/down would bring you to the top/bottom of the grid. (Technically becoming not-like the rest but my brain keeps thinking that's how it should work.)

Either way, it's all up to interpretation and feelings now so I'm good to ship. We can open up a followup ticket if we want to discuss it or wait and see if anyone else opens up issues.

🚀

@thompsongl
Copy link
Contributor

This is ready to review functionality, not yet the code side.

Let me know when this is ready, @chandlerprall

@chandlerprall
Copy link
Contributor Author

@thompsongl this now looks stable for review, thanks!

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Code LGTM. I also (successfully) ran through the scenarios in the docs for good measure

src/components/datagrid/data_grid.tsx Outdated Show resolved Hide resolved
@@ -57,6 +57,13 @@ export class EuiFocusTrap extends Component<Props, State> {
this.setInitialFocus(this.props.initialFocus);
}

componentDidUpdate(prevProps: Props) {
if (prevProps.disabled === true && this.props.disabled === false) {
// eslint-disable-next-line react/no-did-update-set-state
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should open an issue to convert this to a function component. Avoiding this is probably worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I've never cared about this react lint rule. We should convert for the sake of converting, at some point. though. Helps avoid these types of bugs

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Pushed a docs cleanup and did some design stuff on the example. LGTM.

image

@chandlerprall
Copy link
Contributor Author

Will merge on green CI. Thanks everyone!

@kibanamachine
Copy link

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

@chandlerprall chandlerprall merged commit 24bfdb7 into elastic:master Apr 3, 2020
@chandlerprall chandlerprall deleted the bug/2626-datagrid-cell-focus branch April 3, 2020 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiDataGrid] cell focus is broken when only one focusable child
5 participants