-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: add attributes to input and wrapper component #2570
feat: add attributes to input and wrapper component #2570
Conversation
✅ Deploy Preview for paragon-openedx ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
3d11100
to
236afbc
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2570 +/- ##
==========================================
+ Coverage 91.81% 92.25% +0.43%
==========================================
Files 235 235
Lines 4217 4222 +5
Branches 1020 1020
==========================================
+ Hits 3872 3895 +23
+ Misses 341 323 -18
Partials 4 4
☔ View full report in Codecov by Sentry. |
src/Form/FormAutosuggest.jsx
Outdated
// eslint-disable-next-line no-shadow | ||
const { children, onClick, ...rest } = child.props; | ||
// Generate a unique ID for each menu item | ||
const menuItemId = `pgn__form-autosuggest__menuItem-${index}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions here:
- Duplicate IDs are possible here (e.g., if there are multiple
FormAutosuggest
components rendered at the same time in the UI with the same number of children. There might be an opportunity to be usename
to differentiate between multipleFormAutosuggest
components? That said, it doesn't appear to be a required field as is. - Is there a concern if/when the children change order between re-renders? In theory, the
index
would be different between re-renders on each item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems on http://react-autosuggest.js.org/ the ids will update as the items in the dropdown change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the id
changes in all the appropriate places at the same time (which I'm assuming is the same; that is, it doesn't update the ID in one place and leave it unchanged somewhere else), I imagine the re-rendering/re-ordering of React.Children
wouldn't be an issue. Just worth a sanity check :)
@adamstankiewicz just to verify/document decisions from Paragon WG today:
|
@brian-smith-tcril @httpsmenahassan
I'd like to better understand how and why If we truly need it, then we'll need to consider making it a required prop. Ideally, though, the solution for generating unique IDs wouldn't rely on the prop as if it did, we'd need to make a breaking change to make the
If the ID is guaranteed to be unique based on a uuid, I don't think the
We also use this |
@adamstankiewicz if we can avoid making name a required prop and instead just do the uuid thing that works perfectly imo |
9f7ac7e
to
f557bc6
Compare
f557bc6
to
4fd71b4
Compare
3114298
to
e18a794
Compare
e18a794
to
4471d66
Compare
Create IDs for items in dropdown. Add aria-activedescendant attribute to input to identify to assistive technologies which item in the dropdown is being focused. Add aria-live=”assertive” to wrapper component to allow screen readers to read out the number of options in the dropdown.
4471d66
to
2d57bc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
🎉 This PR is included in version 21.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 22.0.0-alpha.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Resolves #2438.
aria-activedescendant
attribute toinput
to identify to assistive technologies which item in the dropdown is being focusedaria-live=”assertive”
to wrapper component to allow screen readers to read out the number of options in the dropdownDeploy Preview
https://deploy-preview-2570--paragon-openedx.netlify.app/components/form/form-autosuggest/
Merge Checklist
wittjeff
andadamstankiewicz
as reviewers on this PR.Post-merge Checklist