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

Further refactor Popover JS module and improve a11y #838

Merged
merged 33 commits into from Feb 25, 2022
Merged

Conversation

sebnitu
Copy link
Owner

@sebnitu sebnitu commented Feb 21, 2022

What changed?

This PR refactors some of the core architecture of the popover JS module and adds some handy new features along with some accessibility enhancements. Popovers now require aria-controls="unique-id" and id="unique-id" attributes for triggers and targets respectively. This removes the need to add additional data attributes for popovers and their triggers.

Another big addition in this PR is the Collection class which Popover extends. This allows for a re-usable pattern to build and interface with collections. Lays the groundwork in collections for modal and drawer modules (#835).

Other changes include:

  • open() and close() methods now take popover IDs.
  • register() and deregister() methods now take popover ID or either popover elements.
  • Deprecate closeAll() in favor of calling close() without a parameter to close all popovers.
  • Each popover object now has built in methods: open(), close() and deregister().
  • Deregister has been refactored to ensure event listeners and object properties are removed.
  • New get() method for retrieving collection entries by any popover object property (defaults to id).
  • Deprecate the need for data attributes to pass override settings in favor of CSS variables.

Todos

  • Introduce new collections class
  • Add methods to popover objects
  • Add ability to pass popover ID to open, close, register and deregister APIs
  • Update tests and add missing coverage
  • Update documentation with new APIs

This PR fixes #834

@sebnitu sebnitu force-pushed the js-module-a11y branch 2 times, most recently from 83dd770 to c08622f Compare February 23, 2022 06:32
@sebnitu sebnitu marked this pull request as ready for review February 24, 2022 04:10
@sebnitu sebnitu merged commit 403aa33 into master Feb 25, 2022
@sebnitu sebnitu deleted the js-module-a11y branch February 25, 2022 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor popover module to require a unique ID for each popover instance
1 participant