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

fix(breadcrumbs): trigger change event on breadcrumbs via keyboard #4769

Merged
merged 3 commits into from
Sep 25, 2024
Merged

Conversation

Rocss
Copy link
Contributor

@Rocss Rocss commented Sep 18, 2024

Description

Due to undefined href attribute, breadcrumb items without hrefs would not trigger change events on keyboard Enter press.
I added a similar fix which is used for sp-sidenav-item, which is a placeholder href value.

Related issue(s)

Fix for #4733

Motivation and context

How has this been tested?

  • Test case 1

    1. Go here
    2. Using the keyboard, navigate through the breadcrumb items and press "Enter"
    3. In the "Actions" addon, you should see the change event was triggered.
  • Did it pass in Desktop?

  • Did it pass in Mobile? - N/A

  • Did it pass in iPad? - N/A

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

Branch preview

Visual regression test results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Copy link

github-actions bot commented Sep 18, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 227.826 kB 216.653 kB 216.619 kB 🏆
Scripts 57.461 kB 52.031 kB 🏆 52.034 kB
Stylesheet 34.362 kB 30.17 kB 30.141 kB 🏆
Document 6.23 kB 5.468 kB 5.463 kB 🏆
Font 126.858 kB 126.633 kB 126.632 kB 🏆

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

@coveralls
Copy link
Collaborator

coveralls commented Sep 18, 2024

Pull Request Test Coverage Report for Build 11017229033

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.209%

Totals Coverage Status
Change from base Build 10940625012: 0.0%
Covered Lines: 32549
Relevant Lines: 32968

💛 - Coveralls

Copy link

github-actions bot commented Sep 18, 2024

Tachometer results

Chrome

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 486.12ms - 491.59ms - faster ✔
1% - 2%
2.63ms - 10.21ms
branch 676 kB 492.64ms - 497.90ms slower ❌
1% - 2%
2.63ms - 10.21ms
-
Firefox

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 789.75ms - 805.57ms - faster ✔
2% - 5%
13.88ms - 37.28ms
branch 676 kB 814.62ms - 831.86ms slower ❌
2% - 5%
13.88ms - 37.28ms
-

@Rocss Rocss marked this pull request as ready for review September 23, 2024 08:11
@Rocss Rocss requested a review from a team as a code owner September 23, 2024 08:11
Rajdeepc
Rajdeepc previously approved these changes Sep 24, 2024
@rubencarvalho
Copy link
Collaborator

Would it work to handle the keydown event and trigger the same action as the click event when the Enter key is pressed?

pseudo-code:

<breadcrumb-item @keydown=${this.handleKeyDown}>

protected handleKeyDown(event: KeyboardEvent): void {
    if (event.key === 'Enter' || event.keyCode === 13) {
        this.handleClick(event);
    }
}

@@ -86,7 +86,9 @@ export class BreadcrumbItem extends LikeAnchor(Focusable) {
return html`
<a
id="item-link"
href=${ifDefined(!this.isLastOfType ? this.href : undefined)}
href=${ifDefined(
!this.isLastOfType ? this.href || '#' : undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this lead to a jump to the top of the page when "#" is set?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! I have updated the changes. Let' see if we can land this for tomorrow's release.

@Rajdeepc Rajdeepc merged commit e14d082 into main Sep 25, 2024
61 checks passed
@Rajdeepc Rajdeepc deleted the 4733 branch September 25, 2024 07:45
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.

5 participants