Skip to content

refactor: do not disable buttons when moving to overflow #9027

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

Merged
merged 1 commit into from
May 2, 2025

Conversation

web-padawan
Copy link
Member

@web-padawan web-padawan commented Apr 30, 2025

Description

Depends on #8871

The original implementation sets button.disabled = true when hiding buttons and moving items to the overflow menu - see vaadin/vaadin-menu-bar#16 (comment). It was needed because back then the menu-bar used its own version of _getAvailableIndex() that checked for disabled and hidden attributes but not for visibility.

Disabling is no longer needed since both Tab and arrow keys are now handled by KeyboardDirectionMixin which filters out hidden buttons using isElementHidden() and that helper checks for visibility property internally.

Updated to not modify disabled on buttons manually so that it can be handled consistently via the Lit template, and modified the observer to call __renderButtons() on disabled property change, the same as as on _theme change.

Also adjusted some tests to not check for tabindex="-1" set on the buttons that are moved to the overflow menu.
This was a side-effect of setting disabled, in fact we don't need to not modify tabindex for those buttons.

Type of change

  • Refactor

@web-padawan web-padawan force-pushed the refactor/menu-bar-buttons-disabled branch from 737cd02 to 4ea0861 Compare May 1, 2025 09:37
@@ -160,22 +143,6 @@ describe('overflow', () => {
await nextResize(menu);

expect(buttons[0].getAttribute('tabindex')).to.equal('0');
expect(buttons[1].getAttribute('tabindex')).to.equal('-1');
Copy link
Member Author

Choose a reason for hiding this comment

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

This check is not so relevant for the test, the actual thing is to ensure tabindex is set to 0 on the first visible button (which had tabindex="-1" before resizing above).

expect(buttons[1].getAttribute('tabindex')).to.equal('-1');
});

it('should set tabindex -1 on the overflow menu in tab navigation', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a copy-paste of the test above. With tabNavigation the logic for setting tabindex="0" on the buttons that remain visible is not needed since all enabled buttons have tabindex="0" by default. Removed the test.

@web-padawan web-padawan force-pushed the refactor/menu-bar-buttons-disabled branch 2 times, most recently from cce9d1c to 2590bd6 Compare May 1, 2025 10:13
@web-padawan web-padawan requested a review from vursen May 1, 2025 10:19
@web-padawan web-padawan force-pushed the refactor/menu-bar-buttons-disabled branch from 2590bd6 to c22ba0c Compare May 1, 2025 15:36
@web-padawan web-padawan marked this pull request as ready for review May 1, 2025 15:36
Copy link

sonarqubecloud bot commented May 1, 2025

@web-padawan web-padawan merged commit 971a22a into main May 2, 2025
9 checks passed
@web-padawan web-padawan deleted the refactor/menu-bar-buttons-disabled branch May 2, 2025 07:50
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