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

Manage the active item via focus instead constant value #81

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mu-hun
Copy link

@mu-hun mu-hun commented Dec 17, 2023

Manage the active item via focus

Most of the AGP documentation, including examples you to manage the keyboard & mouse active item as the focus.

I suggest to change styling at the CSS selectors level if possible, rather than manipulating the styles on the JS side in the examples.

Updated example list

  • listbox, listbox multi
  • combobox, combobox multi (Exclude triggering focus by dd2f1fd issue)
  • menu

Unfortunately, I made it a Draft PR because there is problem at keyboard interaction between Combobox items.

item.node.scrollIntoView({ block: 'nearest' })
item.node.focus()
Copy link
Author

Choose a reason for hiding this comment

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

I removed the scrollIntoView call line because the focus method also functions as a scroll.

@mu-hun mu-hun changed the title Styling examples by :focus and aria-selected instead constant values Manage the active item via focus instead constant value Dec 18, 2023
@CaptainCodeman
Copy link
Owner

CaptainCodeman commented Dec 18, 2023

Thanks for this.

Yeah, I generally think styling based on aria attributes is always better as it helps make them a first-class feature more than an add-on. The original idea was to try to have parity with the official headless lib when it came to the actual HTML & CSS.

The aria-activedescendant option looks better than roving tab index as it seems to cater for having selected + focus be different things, but I read an article that suggested it wasn't consistent across browsers. I was planning on exploring if that was still the case and possibly using it with the next version (Svelte-5 / Runes).

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.

2 participants