You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new feature should improve accessibility and keyboard navigation.
New feature description
Note that limel-dock-buttons contain a button element inside them, which is already focusable, using the Tab key on the keyboard.
But we don't want the user to be using the Tab key to set focus on each individual item. This is the behavior I expect:
Once the component is loaded, the button inside the limel-dock-button should receive focus, as soon as the user tabs into the component. This means the first button should have tabindex="0" and all other buttons in the dock should have tabindex="-1".
Now if the user presses the tab key again, the focus will leave the limel-dock to the next focusable component in the DOM.
However, while one of the buttons in limel-dock is focused, user should be able to navigate with arrow keys, to set the focus on the next or previous button, and toggle the tabindex.
The last focused button in the Dock should be remembered. This means the tabindexes should be remembered. So next time that the user sets the focus inside the limel-dock component, the last item that had tabindex="0"would receive the focus.
When useMobileLayout= true the left and right arrow keys can be used to navigate. Otherwise the top and bottom arrow keys should be used to navigate and set the focus on next and previous items.
New feature implementation
For inspiration
import{// ... existing imports ...}from'@stencil/core';
@Component({// ... existing component configuration ...})exportclassDock{// ... existing properties and methods ...privatefocusedButtonIndex: number=0;// To remember the last focused buttonprivatehandleKeyDown=(event: KeyboardEvent)=>{if(event.key==='ArrowLeft'&&this.useMobileLayout){this.navigateLeft();}elseif(event.key==='ArrowRight'&&this.useMobileLayout){this.navigateRight();}elseif(event.key==='ArrowUp'&&!this.useMobileLayout){this.navigateUp();}elseif(event.key==='ArrowDown'&&!this.useMobileLayout){this.navigateDown();}};privatenavigateLeft(){// Implement logic for left arrow key navigation (if needed)}privatenavigateRight(){// Implement logic for right arrow key navigation (if needed)}privatenavigateUp(){// Implement logic for up arrow key navigation (if needed)}privatenavigateDown(){// Implement logic for down arrow key navigation (if needed)}componentDidLoad(){// Set focus to the first button when the component loadsconstfirstButton=this.getFirstFocusableButton();if(firstButton){firstButton.focus();}// Add event listener for arrow key navigationdocument.addEventListener('keydown',this.handleKeyDown);}disconnectedCallback(){// Remove event listener to avoid memory leaksdocument.removeEventListener('keydown',this.handleKeyDown);}privategetFirstFocusableButton(): HTMLButtonElement|null{constbuttons=this.getDockButtons();returnbuttons[0]||null;}privategetDockButtons(): NodeListOf<HTMLButtonElement>{returnthis.shadowRoot.querySelectorAll('limel-dock-button button');}}
Inspiration for navigateRight()
privatenavigateRight(){constbuttons=this.getDockButtons();constcurrentButton=buttons[this.focusedButtonIndex];if(currentButton){// Remove focus from the current buttoncurrentButton.tabIndex=-1;currentButton.blur();}// Increment the index, cycling back to 0 if at the endthis.focusedButtonIndex=(this.focusedButtonIndex+1)%buttons.length;constnextButton=buttons[this.focusedButtonIndex];if(nextButton){// Set focus to the next buttonnextButton.tabIndex=0;nextButton.focus();}}
⚠️ Important note
We want the same kind of logic in many components (see the umbrella issue). It's better to make a reusable script that can be imported into any component. Some components –depending on their layout of clickable elements–, may need all 4 different directions of the keyboard navigations.
The text was updated successfully, but these errors were encountered:
New feature motivation
The new feature should improve accessibility and keyboard navigation.
New feature description
Note that
limel-dock-button
s contain abutton
element inside them, which is already focusable, using the Tab key on the keyboard.But we don't want the user to be using the Tab key to set focus on each individual item. This is the behavior I expect:
button
inside thelimel-dock-button
should receive focus, as soon as the user tabs into the component. This means the first button should havetabindex="0"
and all other buttons in the dock should havetabindex="-1"
.limel-dock
to the next focusable component in the DOM.limel-dock
is focused, user should be able to navigate with arrow keys, to set the focus on the next or previous button, and toggle thetabindex
.limel-dock
component, the last item that hadtabindex="0"
would receive the focus.useMobileLayout= true
the left and right arrow keys can be used to navigate. Otherwise the top and bottom arrow keys should be used to navigate and set the focus on next and previous items.New feature implementation
For inspiration
Inspiration for
navigateRight()
We want the same kind of logic in many components (see the umbrella issue). It's better to make a reusable script that can be imported into any component. Some components –depending on their layout of clickable elements–, may need all 4 different directions of the keyboard navigations.
The text was updated successfully, but these errors were encountered: