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

[EuiModal] Adjust position of close button #8202

Closed
wants to merge 7 commits into from

Conversation

acstll
Copy link
Contributor

@acstll acstll commented Dec 4, 2024

Summary

Should fix #7222

The close button is placed right after the EuiHeader, if used. Otherwise is placed last.

When this is ready, I'll apply the same logic for #7223

I need to figure out how to properly test the screen reader part.

QA

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • ⚠️ Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
    • If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist
    • If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)

@acstll acstll requested a review from a team as a code owner December 4, 2024 14:40
@acstll
Copy link
Contributor Author

acstll commented Dec 4, 2024

Reading the changelog docs now, will fix 🤓

@acstll acstll self-assigned this Dec 4, 2024
@acstll acstll force-pushed the modal-close-position branch from 11b5c2e to 529ca3e Compare December 4, 2024 14:55
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💔 Build Failed

Failed CI Steps

cc @acstll

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.

I'm sorry to be a blocker on your first PR 🙈 But I'm going to ask us to pause on implementing this PR. I don't think I fully thought through Trevor's proposal when he opened #7222, and I absolutely shouldn't have added the low hanging fruit tag to it. I apologize, that's totally on me.

My concern with this the fallibility of iterating through React.Children:

  • It doesn't handle recursively checking children (e.g. if a consumer uses a <Context.Provider> wrapper around <EuiModalHeader>)
  • It doesn't scale well / has potential performance issues with components with many rerenders and many children (admittedly not likely in production with EuiModal compared to EuiFlyout, but nevertheless not ideal or a best practice)

While those aren't necessarily dealbreaking tradeoffs by themselves, what tips me towards blocking this PR is that I don't feel that the accessibility gain from this, if any, is worthwhile. The inciting feature that Trevor was using an example when he wrote up the original issue was for EuiCallOut, which isn't the same use case at all in terms of screen reader experience:

  • EuiModals already have an aria-labelledby pattern that points to EuiModalHeader/EuiModalTitle, so modals should already have their titles read out automatically on open, unlike callouts
  • EuiModals have a focus trap and separate context / dialog role, so it's important that users be able to quickly exit from them if necessary if they did not mean to open this interrupting dialog

With those considerations in mind, and if our accessibility specialists @alexwizp and @L1nBra agree that EuiModal does not require this change, I personally vote we should instead close #7222 as not planned and leave the close button in its current DOM order.

@acstll
Copy link
Contributor Author

acstll commented Dec 4, 2024

@cee-chen no apology necessary! Thanks for taking a look so quickly and for the extensive explanation 🙂

I wasn't sure about using Children but I saw it's being used in a couple of places so I thought it would be OK. But I didn't think about the possibility of EuiHeader being wrapped, my bad!

While those aren't necessarily dealbreaking tradeoffs by themselves, what tips me towards blocking this PR is that I don't feel that the accessibility gain from this, if any, is worthwhile.

I completely agree with this. I'm also not keen on this implementation and would rather just close this PR (or go with a simpler solution).

From my experience with role=dialog and screen readers, I got the best results recently with the heading element (e.g. h2) being the very first child of the dialog element, unwrapped. And the close button always last. Maybe that's something for the accessibility experts to consider, to leave everything as it is but only place the button last? It would then be a very simple change.

@cee-chen
Copy link
Contributor

cee-chen commented Dec 5, 2024

From my experience with role=dialog and screen readers, I got the best results recently with the heading element (e.g. h2) being the very first child of the dialog element, unwrapped. And the close button always last. Maybe that's something for the accessibility experts to consider, to leave everything as it is but only place the button last? It would then be a very simple change.

Interesting! As long as we convey to screen readers on dialog open that the Escape key works to immediately close out modals/flyouts/popovers etc. immediately without having to navigate all the way to the close button, I'd be good with that - but I'll also defer to any a11y experts or user research on that decision.

@acstll
Copy link
Contributor Author

acstll commented Dec 12, 2024

Closing in favor of #8230

@acstll acstll closed this Dec 12, 2024
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.

[EuiModal] Adjust the source order to announce EuiTitle before Close button
4 participants