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

[Lens] (Accessibility) focus on adding/removing layers #84900

Merged

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Dec 3, 2020

Summary

Fixes #83595

  1. When layer is reset (so there's just one) the focus goes to the layer.

  2. When layer is removed, the focus goes to the layer before it.
    removing

  3. When layer is added, the focus goes to the added layer.
    adding

Adding tabIndex={-1} caused the side effect - now when we click on the layer, it gets selected. I am not sure if it's a problem though
removing

@mbondyra mbondyra added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Lens v7.11.0 labels Dec 3, 2020
@mbondyra mbondyra force-pushed the lens/accessibility/focus-on-lnsConfigPanel branch 3 times, most recently from f35a289 to bedbfc4 Compare December 5, 2020 18:43
@mbondyra mbondyra force-pushed the lens/accessibility/focus-on-lnsConfigPanel branch from 12f62fd to 4219efd Compare December 14, 2020 10:44
@mbondyra mbondyra marked this pull request as ready for review December 14, 2020 10:44
@mbondyra mbondyra requested a review from a team December 14, 2020 10:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@mbondyra mbondyra force-pushed the lens/accessibility/focus-on-lnsConfigPanel branch from 4219efd to 9082efc Compare December 14, 2020 11:03
Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Code looks ok, just a minor comment. Tested locally on Chrome and Firefox and it works as described in the PR description.

TBH I'm not 100% sure about the behaviour here, I understand the focus should go to the first tabbable element, but see that tooltip show up makes me wonder as user I did something wrong.
But if @myasonik is ok then I won't object.

To clarify my concerns are:

  • while it makes sense to put the focus on the first tabbable element, having that tooltip show up confuses me a bit. It would be great to either have the focus without the tooltip or set the focus to the datasource selection maybe?
  • when I have multiple layers and delete it, I would expect the focus to move to the N-1th layer rather than scroll all the way up.

@mbondyra
Copy link
Contributor Author

I agree with both points @dej611 – it's quite unfortunate that the first focusable element in the layer is a tooltip. So far I just implemented it according it to the issue description, but this PR can be an intro to discussion.

@myasonik
Copy link
Contributor

Awesome work @mbondyra!

I understand the annoyance with the tooltip so let's implement something slightly different that still achieves the goal.

For where to place focus

Instead of moving focus to the first tabbable element, you can also move focus to the layer panel overall. You'll need to add tabIndex={-1} so that you can programmatically set focus to it. I'd also recommend making the outermost element of the panel a <section> instead of a <div>. I don't see any support for this in EuiPanel so I'd just wrap it.

TL:DR some final-ish pseudocode of <LayerPanel /> looks like this:

<section tabIndex={-1} panelRef={ref}>
  {/* the contents of layer panel today in here */}
</section>

For delete

@dej611 said:

when I have multiple layers and delete it, I would expect the focus to move to the N-1th layer rather than scroll all the way up.

If y'all agree this would be the more common need, this would also be appropriate. Feel free to move focus to wherever you feel is the most expected next thing the person will need to interact with.

@mbondyra mbondyra requested a review from a team as a code owner December 15, 2020 08:55
@mbondyra
Copy link
Contributor Author

Thanks @myasonik! I've updated the PR, please take a look at the description above before checking the code :)


props.updateAll(datasourceId, newState, nextVisState);
},
<section tabIndex={-1} ref={setLayerRefMemoized}>
Copy link
Contributor Author

@mbondyra mbondyra Dec 15, 2020

Choose a reason for hiding this comment

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

I am surprised that git analyzed this file this way. Line 140 is the only changed line in the whole return statement (I added the section container, so plus its closing).

Copy link
Contributor

Choose a reason for hiding this comment

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

Reviewed with this flag on and it's only 2 lines change:
Screenshot 2020-12-15 at 17 06 17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice!!! Thanks for the tip, I forgot about this!

Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

CSS changes looks good.

Nice enhancement!

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.

LGTM!

If you move the lnsLayerPanel class to the <section>, you can add these styles to it to remove the focus ring for mouse clicks and it doesn't break anything else:

.lnsLayerPanel {
  margin-bottom: $euiSizeS;

  // disable focus ring for mouse clicks, leave it for keyboard users
  &:focus:not(:focus-visible) {
    animation: none !important;
  }
}

(Tested with old and new theme. Won't work if the browser doesn't support focus-visible but the fallback is it just always shows the focus ring so it's not bad.)

@ryankeairns Is that scss change fine?

@mbondyra
Copy link
Contributor Author

@elasticmachine merge upstream

@mbondyra
Copy link
Contributor Author

mbondyra commented Dec 16, 2020

Hey @myasonik does that mean we don't want to show focus ring at all, both for mouse and keyboard users when user removes/adds a layer? I am ok with it, but just making sure because that's how it works for Chrome. For FF and Safari it doesn't give any effect.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.0MB 1.0MB +3.7KB

Distributable file count

id before after diff
default 47280 48040 +760

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ryankeairns
Copy link
Contributor

LGTM!

If you move the lnsLayerPanel class to the <section>, you can add these styles to it to remove the focus ring for mouse clicks and it doesn't break anything else:

.lnsLayerPanel {
  margin-bottom: $euiSizeS;

  // disable focus ring for mouse clicks, leave it for keyboard users
  &:focus:not(:focus-visible) {
    animation: none !important;
  }
}

(Tested with old and new theme. Won't work if the browser doesn't support focus-visible but the fallback is it just always shows the focus ring so it's not bad.)

@ryankeairns Is that scss change fine?

Yep, looks good. Thanks for walking me through the example.

@myasonik
Copy link
Contributor

@mbondyra Just tested this locally and everything seems to work as expected for me

@mbondyra mbondyra merged commit 5b9e285 into elastic:master Dec 16, 2020
@mbondyra mbondyra deleted the lens/accessibility/focus-on-lnsConfigPanel branch December 16, 2020 20:58
mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 16, 2020
@mbondyra mbondyra added v7.12.0 and removed v7.11.0 labels Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] (Accessibility) Focus is lost when deleting a layer
6 participants