Skip to content

fix: fire click on Enter and Space, but not when disabled - #2438

Merged
web-padawan merged 4 commits into
masterfrom
fix/button/trigger-click
Sep 3, 2021
Merged

web-padawan merged 4 commits into
masterfrom
fix/button/trigger-click

Conversation

@vursen

@vursen vursen commented Sep 2, 2021 •

Copy link
Copy Markdown
Contributor

Description

The PR fixes the regression that occurred after we released the new @vaadin/button package:

The click event doesn't get fired on the button once the user presses an activation key (Enter, Space) so that the button ends up not fully accessible by the keyboard.

Note, <vaadin-drawer-toggle> now fires the drawer-toggle-click event on keydown rather than keyup the way it was before. This might be considered as a breaking-change.

Fixes #2437

WARNING: Please, do not merge this PR before #2432 is merged. (merged)

Specs

Type of change

  • Bugfix

Checklist

  • I have read the contribution guide: https://vaadin.com/docs-beta/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@vursen
vursen requested a review from web-padawan September 2, 2021 13:20
@vursen
vursen force-pushed the fix/button/trigger-click branch 5 times, most recently from 24d1c9d to 9487735 Compare September 2, 2021 14:03
@vursen
vursen force-pushed the fix/button/trigger-click branch from 9487735 to b359935 Compare September 3, 2021 08:32
@vursen
vursen force-pushed the fix/button/trigger-click branch from b359935 to c80cdaf Compare September 3, 2021 08:34

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like updating drawer toggle caused its tests to fail:

 ❌ drawer-toggle > click event > disabled > should not fire "drawer-toggle-click" event on click when disabled
      AssertionError: expected true to be false
      + expected - actual
      
      -true
      +false

I would say this should be fixed by adding this missing logic:

/**
* @protected
*/
click() {
if (!this.disabled) {
super.click();
}
}

This logic is present in DelegatesFocusMixin but it also needs to be added to Button.

@vursen

vursen commented Sep 3, 2021 •

Copy link
Copy Markdown
Contributor Author

This logic is present in DelegatesFocusMixin but it also needs to be added to Button.

@web-padawan Added a similar logic to DisabledMixin as it was agreed in our Slack discussion.

@web-padawan web-padawan changed the title fix: fire click event on enter and space fix: fire click on Enter and Space, but not when disabled Sep 3, 2021
@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2021

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed that GridDelegateFocusToComponentIT.focusButton passes locally with the fix.

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with platform 22.0.0.alpha3 and is also targeting the upcoming stable 22.0.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[button] Regression: click event not fired on keydown events

3 participants