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(toast): Toast should have API for overriding the icon's alt text #4159

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

susmithayenugula
Copy link
Contributor

@susmithayenugula susmithayenugula commented Mar 8, 2024

Added label prop to Toast that allows customization of the sp-icon's label.

Description

  • Previously, the label for the sp-icon used in a sp-toast was hardcoded to Success, Error and Information for positive, negative and info toasts.
  • The addition of the label prop allows one to customize the string. This is useful when we want to use the string Warning for a negative toast.
  • Update storybook to add label prop and set value of this prop.

Related issue(s)

fixes #3406

Motivation and context

The addition of the label prop allows one to customize the string. This is useful when we want to use the string Warning for a negative toast.

How has this been tested?

  1. Navigate to storybook locally
  2. Go to the Toast component in the sidebar.
  3. In DevTools, select the icon with the inspect tool. sp-icon-x is in sp-toast's shadow-root.
  4. Notice in the Controls tab, locate the new attribute label.
  5. Type in any string and re-render the toast using Remount component in the top bar.
  6. Verify that the string typed in step 4 is the present under the label prop of sp-icon-x.

Screenshots (if appropriate)

Screenshot 2024-03-07 at 10 19 37 PM

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.

@@ -36,6 +36,7 @@ export class IconBase extends SpectrumElement {
if (changes.has('label')) {
if (this.label) {
this.removeAttribute('aria-hidden');
this.setAttribute('aria-label', this.label);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per the readme for icon:

aria-hidden is set to true by default for Icons. The label attribute suppresses this and adds the label text as the aria-label of the icon.

This was not implemented so fixed it in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why we don't use aria-label from the component tag instead of introducing a new label property? I removed the custom label property and use the aria-label that can be specified at the component level

Copy link
Collaborator

Choose a reason for hiding this comment

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

At the API level we generally use label because sometimes that element must be labeled at the host (which would be the same as using aria-label, but other times that label needs to be applied to something within the host, and forwarding aria-label is a tricky accessibility/timing cup game of dispair. Having a single entry point across as many elements as possible intends that it is less likely that a consumer makes the mistake of using the wrong one when switching back and forth between them over the course of developing a larger application.

Copy link

github-actions bot commented Mar 8, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.97 0.97 0.97
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 229.679 kB 217.347 kB 🏆 228.87 kB
Scripts 61.382 kB 54.404 kB 🏆 54.673 kB
Stylesheet 35.702 kB 30.975 kB 🏆 42.31 kB
Document 5.883 kB 5.256 kB 5.175 kB 🏆
Third Party 126.712 kB 126.712 kB 126.712 kB

Request Count

Category Latest Main Branch
Total 43 43 43
Scripts 35 35 35
Stylesheet 5 5 5
Document 1 1 1
Third Party 2 2 2

await elementUpdated(el);

await expect(el.getAttribute('label')).to.equal('testLabel');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't check if the sp-icon's label in this test since sp-icon isn't exposed in sp-toast

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you try getting it through the shadowRoot? So:

el.shadowRoot.querySelector(
   sp-icon-checkmark-circle
) as HTMLElement;

I see that used in https://github.com/adobe/spectrum-web-components/blob/main/packages/tray/test/tray.test.ts#L105

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sarahszhou Thank you, worked perfectly!

private _variant: ToastVariants = '';

private renderIcon(variant: string): TemplateResult {
private _label: string = '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure but seems like changing the default string to be an empty string as opposed to the existing Success, Error, and Information seems like it could break things?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, if the consumer does not define a label, should we fall back to the existing strings?

Suggested change
private _label: string = '';
<sp-icon-info label=${label === "" ? "Information" : label} class="type"></sp-icon-info>

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah falling back to the default makes sense to me!

Copy link

github-actions bot commented Mar 8, 2024

Tachometer results

Chrome

accordion permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 415 kB 130.49ms - 133.46ms - faster ✔
0% - 3%
0.26ms - 4.35ms
branch 406 kB 132.87ms - 135.68ms slower ❌
0% - 3%
0.26ms - 4.35ms
-

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 483 kB 69.02ms - 72.03ms - unsure 🔍
-4% - +2%
-2.77ms - +1.26ms
branch 474 kB 69.93ms - 72.62ms unsure 🔍
-2% - +4%
-1.26ms - +2.77ms
-

action-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 513 kB 100.97ms - 102.84ms - unsure 🔍
-0% - +2%
-0.11ms - +2.40ms
branch 504 kB 99.92ms - 101.59ms unsure 🔍
-2% - +0%
-2.40ms - +0.11ms
-

action-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 535 kB 64.51ms - 65.79ms - slower ❌
0% - 3%
0.26ms - 2.12ms
branch 526 kB 63.29ms - 64.64ms faster ✔
0% - 3%
0.26ms - 2.12ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 645 kB 161.94ms - 165.60ms - unsure 🔍
-1% - +3%
-1.42ms - +4.46ms
branch 637 kB 159.94ms - 164.55ms unsure 🔍
-3% - +1%
-4.46ms - +1.42ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 87.57ms - 88.93ms - unsure 🔍
-2% - +1%
-1.42ms - +0.50ms
branch 594 kB 88.03ms - 89.39ms unsure 🔍
-1% - +2%
-0.50ms - +1.42ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 85.66ms - 87.17ms - unsure 🔍
-1% - +1%
-0.78ms - +1.19ms
branch 593 kB 85.58ms - 86.85ms unsure 🔍
-1% - +1%
-1.19ms - +0.78ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 785 kB 1868.80ms - 1872.29ms - unsure 🔍
-0% - +0%
-4.29ms - +0.49ms
branch 777 kB 1870.81ms - 1874.08ms unsure 🔍
-0% - +0%
-0.49ms - +4.29ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 783 kB 1857.34ms - 1860.21ms - unsure 🔍
-0% - +0%
-1.78ms - +1.94ms
branch 775 kB 1857.52ms - 1859.87ms unsure 🔍
-0% - +0%
-1.94ms - +1.78ms
-

alert-dialog permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 455 kB 96.36ms - 97.52ms - unsure 🔍
-1% - +1%
-0.67ms - +0.88ms
branch 442 kB 96.32ms - 97.34ms unsure 🔍
-1% - +1%
-0.88ms - +0.67ms
-

button-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 442 kB 58.83ms - 59.92ms - unsure 🔍
-0% - +2%
-0.21ms - +1.44ms
branch 433 kB 58.14ms - 59.38ms unsure 🔍
-2% - +0%
-1.44ms - +0.21ms
-

button permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 449 kB 69.72ms - 71.04ms - slower ❌
1% - 3%
0.37ms - 2.23ms
branch 439 kB 68.42ms - 69.73ms faster ✔
1% - 3%
0.37ms - 2.23ms
-

card permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 501 kB 58.32ms - 59.28ms - unsure 🔍
-1% - +1%
-0.44ms - +0.85ms
branch 493 kB 58.16ms - 59.02ms unsure 🔍
-1% - +1%
-0.85ms - +0.44ms
-

checkbox permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 414 kB 68.97ms - 70.01ms - faster ✔
1% - 3%
0.64ms - 2.42ms
branch 406 kB 70.30ms - 71.74ms slower ❌
1% - 3%
0.64ms - 2.42ms
-

coachmark permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 626 kB 112.25ms - 114.83ms - unsure 🔍
-1% - +2%
-0.86ms - +2.47ms
branch 617 kB 111.69ms - 113.79ms unsure 🔍
-2% - +1%
-2.47ms - +0.86ms
-

color-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 484 kB 51.87ms - 52.68ms - faster ✔
6% - 8%
3.18ms - 4.42ms
branch 476 kB 55.61ms - 56.55ms slower ❌
6% - 8%
3.18ms - 4.42ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 36.00ms - 36.52ms - faster ✔
1% - 3%
0.42ms - 1.07ms
branch 697 kB 36.80ms - 37.21ms slower ❌
1% - 3%
0.42ms - 1.07ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 382.20ms - 388.92ms - unsure 🔍
-1% - +1%
-5.51ms - +2.96ms
branch 697 kB 384.26ms - 389.41ms unsure 🔍
-1% - +1%
-2.96ms - +5.51ms
-

dialog permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 507 kB 70.44ms - 71.15ms - faster ✔
0% - 2%
0.28ms - 1.51ms
branch 498 kB 71.18ms - 72.20ms slower ❌
0% - 2%
0.28ms - 1.51ms
-

field-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 420 kB 80.63ms - 82.07ms - faster ✔
2% - 4%
1.80ms - 3.70ms
branch 412 kB 83.48ms - 84.71ms slower ❌
2% - 5%
1.80ms - 3.70ms
-

field-label permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 390 kB 24.96ms - 25.25ms - faster ✔
2% - 4%
0.60ms - 1.06ms
branch 381 kB 25.76ms - 26.11ms slower ❌
2% - 4%
0.60ms - 1.06ms
-

help-text permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 386 kB 14.63ms - 14.76ms - unsure 🔍
-2% - +1%
-0.26ms - +0.20ms
branch 377 kB 14.51ms - 14.94ms unsure 🔍
-1% - +2%
-0.20ms - +0.26ms
-

icon permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 393 kB 17.89ms - 18.03ms - faster ✔
9% - 10%
1.75ms - 1.99ms
branch 385 kB 19.73ms - 19.93ms slower ❌
10% - 11%
1.75ms - 1.99ms
-

infield-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 401 kB 19.27ms - 19.50ms - slower ❌
2% - 3%
0.32ms - 0.64ms
branch 392 kB 18.79ms - 19.02ms faster ✔
2% - 3%
0.32ms - 0.64ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 473 kB 201.03ms - 205.34ms - unsure 🔍
-1% - +2%
-2.08ms - +3.29ms
branch 466 kB 200.98ms - 204.18ms unsure 🔍
-2% - +1%
-3.29ms - +2.08ms
-

meter permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 405 kB 56.08ms - 56.68ms - faster ✔
2% - 4%
1.23ms - 2.14ms
branch 397 kB 57.72ms - 58.41ms slower ❌
2% - 4%
1.23ms - 2.14ms
-

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 521 kB 91.35ms - 93.14ms - faster ✔
3% - 5%
2.53ms - 5.01ms
branch 512 kB 95.15ms - 96.87ms slower ❌
3% - 5%
2.53ms - 5.01ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 671 kB 456.31ms - 459.89ms - unsure 🔍
-1% - +0%
-4.71ms - +1.44ms
branch 663 kB 457.23ms - 462.24ms unsure 🔍
-0% - +1%
-1.44ms - +4.71ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 786 kB 35.10ms - 35.62ms - slower ❌
0% - 2%
0.16ms - 0.86ms
branch 766 kB 34.61ms - 35.09ms faster ✔
0% - 2%
0.16ms - 0.86ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 756 kB 340.26ms - 343.76ms - faster ✔
0% - 2%
0.01ms - 5.38ms
branch 749 kB 342.68ms - 346.74ms slower ❌
0% - 2%
0.01ms - 5.38ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 557 kB 52.93ms - 53.83ms - unsure 🔍
-0% - +2%
-0.24ms - +1.08ms
branch 549 kB 52.48ms - 53.45ms unsure 🔍
-2% - +0%
-1.08ms - +0.24ms
-

picker-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 413 kB 37.43ms - 38.00ms - slower ❌
0% - 2%
0.05ms - 0.83ms
branch 404 kB 37.01ms - 37.54ms faster ✔
0% - 2%
0.05ms - 0.83ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 511 kB 558.33ms - 567.12ms - unsure 🔍
-0% - +2%
-1.02ms - +10.33ms
branch 503 kB 554.48ms - 561.66ms unsure 🔍
-2% - +0%
-10.33ms - +1.02ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 382 kB 21.14ms - 21.68ms - unsure 🔍
-0% - +2%
-0.08ms - +0.47ms
branch 373 kB 21.14ms - 21.28ms unsure 🔍
-2% - +0%
-0.47ms - +0.08ms
-

progress-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 406 kB 44.85ms - 45.55ms - faster ✔
1% - 3%
0.42ms - 1.41ms
branch 398 kB 45.76ms - 46.46ms slower ❌
1% - 3%
0.42ms - 1.41ms
-

radio permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 405 kB 58.27ms - 59.04ms - faster ✔
3% - 5%
2.02ms - 3.16ms
branch 396 kB 60.83ms - 61.67ms slower ❌
3% - 5%
2.02ms - 3.16ms
-

search permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 471 kB 56.67ms - 57.52ms - faster ✔
4% - 6%
2.23ms - 3.67ms
branch 462 kB 59.46ms - 60.63ms slower ❌
4% - 6%
2.23ms - 3.67ms
-

slider permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 477 kB 102.69ms - 105.95ms - unsure 🔍
-2% - +2%
-2.27ms - +1.59ms
branch 469 kB 103.63ms - 105.70ms unsure 🔍
-2% - +2%
-1.59ms - +2.27ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 1856.17ms - 1859.36ms - unsure 🔍
-0% - +0%
-1.78ms - +2.64ms
branch 710 kB 1855.81ms - 1858.87ms unsure 🔍
-0% - +0%
-2.64ms - +1.78ms
-

swatch permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 406 kB 23.32ms - 23.78ms - slower ❌
0% - 2%
0.06ms - 0.58ms
branch 398 kB 23.10ms - 23.36ms faster ✔
0% - 2%
0.06ms - 0.58ms
-

switch permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 399 kB 25.11ms - 25.44ms - unsure 🔍
-0% - +2%
-0.01ms - +0.46ms
branch 390 kB 24.88ms - 25.22ms unsure 🔍
-2% - +0%
-0.46ms - +0.01ms
-

table permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 530 kB 241.45ms - 244.87ms - faster ✔
1% - 3%
1.79ms - 7.19ms
branch 497 kB 245.56ms - 249.74ms slower ❌
1% - 3%
1.79ms - 7.19ms
-

tabs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 422 kB 100.96ms - 102.34ms - faster ✔
3% - 5%
3.14ms - 5.10ms
branch 414 kB 105.08ms - 106.46ms slower ❌
3% - 5%
3.14ms - 5.10ms
-

tags permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 449 kB 20.13ms - 20.49ms - unsure 🔍
-3% - +1%
-0.58ms - +0.12ms
branch 439 kB 20.24ms - 20.84ms unsure 🔍
-1% - +3%
-0.12ms - +0.58ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 431 kB 36.85ms - 37.44ms - faster ✔
5% - 7%
1.91ms - 2.80ms
branch 423 kB 39.17ms - 39.83ms slower ❌
5% - 8%
1.91ms - 2.80ms
-

toast permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 430 kB 42.66ms - 44.03ms - unsure 🔍
-2% - +2%
-0.83ms - +0.78ms
branch 421 kB 42.95ms - 43.80ms unsure 🔍
-2% - +2%
-0.78ms - +0.83ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 554 kB 44.01ms - 45.76ms - slower ❌
1% - 5%
0.34ms - 2.22ms
branch 545 kB 43.26ms - 43.96ms faster ✔
1% - 5%
0.34ms - 2.22ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 644 kB 35.44ms - 35.98ms - slower ❌
0% - 2%
0.05ms - 0.87ms
branch 625 kB 34.94ms - 35.55ms faster ✔
0% - 2%
0.05ms - 0.87ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 62.15ms - 64.01ms - unsure 🔍
-1% - +2%
-0.59ms - +1.49ms
branch 642 kB 62.16ms - 63.09ms unsure 🔍
-2% - +1%
-1.49ms - +0.59ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 628 kB 52.27ms - 52.92ms - unsure 🔍
-2% - +1%
-0.83ms - +0.38ms
branch 619 kB 52.31ms - 53.33ms unsure 🔍
-1% - +2%
-0.38ms - +0.83ms
-

top-nav permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 428 kB 74.21ms - 75.43ms - faster ✔
0% - 4%
0.20ms - 2.96ms
branch 420 kB 75.15ms - 77.63ms slower ❌
0% - 4%
0.20ms - 2.96ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 56.52ms - 57.54ms - unsure 🔍
-1% - +1%
-0.83ms - +0.54ms
branch 515 kB 56.72ms - 57.63ms unsure 🔍
-1% - +1%
-0.54ms - +0.83ms
-
Firefox

accordion permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 415 kB 244.91ms - 255.89ms - unsure 🔍
-5% - +0%
-13.17ms - +1.33ms
branch 406 kB 251.58ms - 261.06ms unsure 🔍
-1% - +5%
-1.33ms - +13.17ms
-

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 483 kB 130.99ms - 138.41ms - unsure 🔍
-4% - +3%
-5.49ms - +3.45ms
branch 474 kB 133.24ms - 138.20ms unsure 🔍
-3% - +4%
-3.45ms - +5.49ms
-

action-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 513 kB 211.49ms - 219.39ms - unsure 🔍
-4% - +2%
-9.47ms - +3.67ms
branch 504 kB 213.09ms - 223.59ms unsure 🔍
-2% - +4%
-3.67ms - +9.47ms
-

action-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 535 kB 147.35ms - 153.21ms - unsure 🔍
-4% - +2%
-6.19ms - +3.11ms
branch 526 kB 148.21ms - 155.43ms unsure 🔍
-2% - +4%
-3.11ms - +6.19ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 645 kB 300.93ms - 304.43ms - faster ✔
7% - 9%
22.53ms - 28.19ms
branch 637 kB 325.82ms - 330.26ms slower ❌
7% - 9%
22.53ms - 28.19ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 153.48ms - 155.84ms - unsure 🔍
-2% - +0%
-3.21ms - +0.61ms
branch 594 kB 154.45ms - 157.47ms unsure 🔍
-0% - +2%
-0.61ms - +3.21ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 173.15ms - 176.97ms - slower ❌
5% - 9%
8.31ms - 14.53ms
branch 593 kB 161.19ms - 166.09ms faster ✔
5% - 8%
8.31ms - 14.53ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 785 kB 1472.02ms - 1478.42ms - slower ❌
2% - 3%
29.97ms - 37.43ms
branch 777 kB 1439.62ms - 1443.42ms faster ✔
2% - 3%
29.97ms - 37.43ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 783 kB 1462.67ms - 1465.89ms - unsure 🔍
-0% - +0%
-5.49ms - +0.41ms
branch 775 kB 1464.35ms - 1469.29ms unsure 🔍
-0% - +0%
-0.41ms - +5.49ms
-

alert-dialog permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 455 kB 190.57ms - 197.67ms - unsure 🔍
-2% - +2%
-4.75ms - +4.59ms
branch 442 kB 191.16ms - 197.24ms unsure 🔍
-2% - +2%
-4.59ms - +4.75ms
-

button-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 442 kB 127.25ms - 134.47ms - unsure 🔍
-4% - +5%
-5.07ms - +6.79ms
branch 433 kB 125.30ms - 134.70ms unsure 🔍
-5% - +4%
-6.79ms - +5.07ms
-

button permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 449 kB 138.76ms - 145.48ms - unsure 🔍
-5% - +2%
-7.84ms - +3.12ms
branch 439 kB 140.15ms - 148.81ms unsure 🔍
-2% - +6%
-3.12ms - +7.84ms
-

card permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 501 kB 104.45ms - 111.43ms - unsure 🔍
-2% - +7%
-1.57ms - +7.57ms
branch 493 kB 101.99ms - 107.89ms unsure 🔍
-7% - +1%
-7.57ms - +1.57ms
-

checkbox permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 414 kB 144.26ms - 152.02ms - unsure 🔍
-6% - +1%
-9.55ms - +1.27ms
branch 406 kB 148.51ms - 156.05ms unsure 🔍
-1% - +6%
-1.27ms - +9.55ms
-

coachmark permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 626 kB 361.21ms - 369.99ms - unsure 🔍
-1% - +2%
-4.88ms - +8.08ms
branch 617 kB 359.23ms - 368.77ms unsure 🔍
-2% - +1%
-8.08ms - +4.88ms
-

color-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 492 kB 96.07ms - 100.89ms - faster ✔
3% - 9%
3.16ms - 9.24ms
branch 483 kB 102.83ms - 106.53ms slower ❌
3% - 10%
3.16ms - 9.24ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 62.53ms - 67.39ms - slower ❌
5% - 13%
2.91ms - 7.97ms
branch 697 kB 58.81ms - 60.23ms faster ✔
5% - 12%
2.91ms - 7.97ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 707.02ms - 723.62ms - slower ❌
3% - 7%
18.00ms - 44.28ms
branch 697 kB 673.99ms - 694.37ms faster ✔
3% - 6%
18.00ms - 44.28ms
-

dialog permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 507 kB 110.57ms - 117.07ms - unsure 🔍
-7% - +1%
-7.81ms - +1.21ms
branch 498 kB 113.98ms - 120.26ms unsure 🔍
-1% - +7%
-1.21ms - +7.81ms
-

field-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 420 kB 171.82ms - 178.30ms - faster ✔
1% - 7%
2.28ms - 13.80ms
branch 412 kB 178.34ms - 187.86ms slower ❌
1% - 8%
2.28ms - 13.80ms
-

field-label permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 390 kB 58.07ms - 62.37ms - faster ✔
1% - 12%
0.49ms - 7.75ms
branch 381 kB 61.41ms - 67.27ms slower ❌
1% - 13%
0.49ms - 7.75ms
-

help-text permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 386 kB 28.54ms - 30.34ms - unsure 🔍
-2% - +5%
-0.55ms - +1.43ms
branch 377 kB 28.57ms - 29.43ms unsure 🔍
-5% - +2%
-1.43ms - +0.55ms
-

icon permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 393 kB 34.76ms - 37.20ms - faster ✔
4% - 11%
1.38ms - 4.46ms
branch 385 kB 37.95ms - 39.85ms slower ❌
4% - 13%
1.38ms - 4.46ms
-

infield-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 401 kB 43.37ms - 45.23ms - unsure 🔍
-3% - +4%
-1.10ms - +1.94ms
branch 392 kB 42.67ms - 45.09ms unsure 🔍
-4% - +2%
-1.94ms - +1.10ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 473 kB 417.76ms - 429.60ms - unsure 🔍
-1% - +2%
-4.49ms - +10.41ms
branch 466 kB 416.20ms - 425.24ms unsure 🔍
-2% - +1%
-10.41ms - +4.49ms
-

meter permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 405 kB 94.17ms - 99.23ms - unsure 🔍
-5% - +2%
-5.36ms - +1.64ms
branch 397 kB 96.14ms - 100.98ms unsure 🔍
-2% - +6%
-1.64ms - +5.36ms
-

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 521 kB 191.44ms - 200.24ms - unsure 🔍
-5% - +0%
-10.82ms - +1.02ms
branch 512 kB 196.79ms - 204.69ms unsure 🔍
-1% - +6%
-1.02ms - +10.82ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 763 kB 653.01ms - 661.51ms - slower ❌
4% - 5%
22.92ms - 32.56ms
branch 755 kB 627.25ms - 631.79ms faster ✔
4% - 5%
22.92ms - 32.56ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 767 kB 65.34ms - 67.46ms - unsure 🔍
-1% - +3%
-0.38ms - +2.02ms
branch 759 kB 65.03ms - 66.13ms unsure 🔍
-3% - +1%
-2.02ms - +0.38ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 756 kB 606.26ms - 621.26ms - slower ❌
3% - 6%
15.59ms - 32.37ms
branch 749 kB 586.01ms - 593.55ms faster ✔
3% - 5%
15.59ms - 32.37ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 557 kB 110.65ms - 114.31ms - slower ❌
10% - 13%
9.61ms - 13.43ms
branch 549 kB 100.42ms - 101.50ms faster ✔
9% - 12%
9.61ms - 13.43ms
-

picker-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 413 kB 76.62ms - 80.46ms - unsure 🔍
-7% - +1%
-5.84ms - +0.92ms
branch 404 kB 78.21ms - 83.79ms unsure 🔍
-1% - +7%
-0.92ms - +5.84ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 511 kB 1007.07ms - 1034.13ms - slower ❌
1% - 4%
9.23ms - 37.73ms
branch 503 kB 992.66ms - 1001.58ms faster ✔
1% - 4%
9.23ms - 37.73ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 382 kB 41.86ms - 47.14ms - unsure 🔍
-9% - +8%
-3.84ms - +3.56ms
branch 373 kB 42.05ms - 47.23ms unsure 🔍
-8% - +9%
-3.56ms - +3.84ms
-

progress-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 406 kB 77.65ms - 83.75ms - unsure 🔍
-7% - +3%
-5.37ms - +2.69ms
branch 398 kB 79.40ms - 84.68ms unsure 🔍
-3% - +7%
-2.69ms - +5.37ms
-

radio permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 405 kB 111.49ms - 118.71ms - unsure 🔍
-8% - +1%
-9.70ms - +1.50ms
branch 396 kB 114.92ms - 123.48ms unsure 🔍
-1% - +9%
-1.50ms - +9.70ms
-

search permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 471 kB 97.04ms - 104.24ms - faster ✔
0% - 10%
0.16ms - 10.56ms
branch 462 kB 102.25ms - 109.75ms slower ❌
0% - 11%
0.16ms - 10.56ms
-

slider permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 477 kB 193.11ms - 199.29ms - unsure 🔍
-4% - +1%
-7.87ms - +1.63ms
branch 469 kB 195.71ms - 202.93ms unsure 🔍
-1% - +4%
-1.63ms - +7.87ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 1428.96ms - 1432.52ms - unsure 🔍
-0% - +0%
-1.52ms - +3.32ms
branch 710 kB 1428.20ms - 1431.48ms unsure 🔍
-0% - +0%
-3.32ms - +1.52ms
-

swatch permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 406 kB 52.75ms - 58.05ms - unsure 🔍
-4% - +9%
-2.12ms - +4.88ms
branch 398 kB 51.74ms - 56.30ms unsure 🔍
-9% - +4%
-4.88ms - +2.12ms
-

switch permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 399 kB 53.43ms - 57.21ms - unsure 🔍
-3% - +6%
-1.72ms - +3.04ms
branch 390 kB 53.22ms - 56.10ms unsure 🔍
-5% - +3%
-3.04ms - +1.72ms
-

table permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 530 kB 404.62ms - 415.66ms - unsure 🔍
-3% - +1%
-10.72ms - +4.92ms
branch 497 kB 407.50ms - 418.58ms unsure 🔍
-1% - +3%
-4.92ms - +10.72ms
-

tabs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 422 kB 189.53ms - 197.95ms - faster ✔
1% - 7%
1.17ms - 13.19ms
branch 414 kB 196.62ms - 205.22ms slower ❌
1% - 7%
1.17ms - 13.19ms
-

tags permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 449 kB 38.79ms - 41.41ms - unsure 🔍
-7% - +2%
-3.12ms - +0.96ms
branch 439 kB 39.62ms - 42.74ms unsure 🔍
-2% - +8%
-0.96ms - +3.12ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 431 kB 75.65ms - 81.39ms - unsure 🔍
-9% - +0%
-7.30ms - +0.38ms
branch 423 kB 79.44ms - 84.52ms unsure 🔍
-1% - +9%
-0.38ms - +7.30ms
-

toast permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 430 kB 84.63ms - 90.01ms - unsure 🔍
-4% - +5%
-3.17ms - +4.17ms
branch 421 kB 84.33ms - 89.31ms unsure 🔍
-5% - +4%
-4.17ms - +3.17ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 95.10ms - 99.70ms - slower ❌
6% - 15%
5.91ms - 12.61ms
branch 642 kB 85.70ms - 90.58ms faster ✔
6% - 13%
5.91ms - 12.61ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 631 kB 67.05ms - 69.19ms - faster ✔
21% - 27%
18.44ms - 24.64ms
branch 623 kB 86.75ms - 92.57ms slower ❌
27% - 36%
18.44ms - 24.64ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 131.46ms - 136.78ms - unsure 🔍
-2% - +4%
-2.43ms - +4.75ms
branch 642 kB 130.55ms - 135.37ms unsure 🔍
-4% - +2%
-4.75ms - +2.43ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 628 kB 109.82ms - 114.06ms - unsure 🔍
-1% - +5%
-1.21ms - +5.01ms
branch 619 kB 107.77ms - 112.31ms unsure 🔍
-4% - +1%
-5.01ms - +1.21ms
-

top-nav permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 428 kB 130.97ms - 139.47ms - unsure 🔍
-6% - +3%
-8.49ms - +4.05ms
branch 420 kB 132.84ms - 142.04ms unsure 🔍
-3% - +6%
-4.05ms - +8.49ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 100.60ms - 106.76ms - unsure 🔍
-5% - +3%
-5.76ms - +3.04ms
branch 515 kB 101.90ms - 108.18ms unsure 🔍
-3% - +6%
-3.04ms - +5.76ms
-

@Rajdeepc Rajdeepc added Component: Toast a11y Issues related to accessibility labels Mar 13, 2024
@Rajdeepc Rajdeepc self-requested a review March 14, 2024 14:31
@Rajdeepc
Copy link
Contributor

Hi @susmithayenugula This PR is pointing to acpc/hackathon-swc. Please catch this up to main and we can take this forward.

@susmithayenugula
Copy link
Contributor Author

@Rajdeepc I'll take care of this today, thank you!

@susmithayenugula susmithayenugula changed the base branch from acpc/hackathon-swc to main March 31, 2024 05:03
@susmithayenugula
Copy link
Contributor Author

Hi @Rajdeepc , I've updated the PR as requested. Please take a look!

@@ -26,7 +26,7 @@ export class IconBase extends SpectrumElement {
return [iconStyles];
}

@property()
@property({ type: String, reflect: true })
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the benefit of reflecting here?

@@ -36,6 +36,7 @@ export class IconBase extends SpectrumElement {
if (changes.has('label')) {
if (this.label) {
this.removeAttribute('aria-hidden');
this.setAttribute('aria-label', this.label);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great add. However, this whole updated method probably should be moved to Icon.ts instead. Some IconBase.ts extensions will pass the label data into an icon literal, which also manages aria-hidden, however these management would be beneficial to the <sp-icon> element as it accepts a slotted icon rather than owning icon DOM itself.

Comment on lines +119 to +128
@property({ type: String })
public set label(label: string) {
this._label = label;
this.setAttribute('label', label);
this.requestUpdate('label', label);
}

public get label(): string {
return this._label;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not use a simple decorator here:

@property()
label = '';

And then avoid all the rest of the manual administration?

As far as naming, this isn't so much the label of the toast as much as the label of the icon. Should we have a more specific attribute/property name that represents that? Which ever way we go, it'll be good to have a JSDoc description as to how the value is leveraged within the element.

switch (variant) {
case 'info':
return html`
<sp-icon-info
label="Information"
label=${label === '' ? 'Information' : label}
Copy link
Collaborator

Choose a reason for hiding this comment

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

'' is falsy, so this can be simplified to label || 'Information'.

Comment on lines +78 to +91
const getIconType = (): string => {
switch (variant) {
case 'info':
return 'sp-icon-info';
case 'negative':
case 'error': // deprecated
case 'warning': // deprecated
return 'sp-icon-alert';
case 'positive':
return 'sp-icon-checkmark-circle';
default:
return '';
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be alleviated by the fact that the icon always has class="type"?

Comment on lines +109 to +130
let iconType;
let defaultLabel;
switch (variant) {
case 'info':
iconType = 'sp-icon-info';
defaultLabel = 'Information';
break;
case 'negative':
case 'error': // deprecated
case 'warning': // deprecated
iconType = 'sp-icon-alert';
defaultLabel = 'Error';
break;
case 'positive':
iconType = 'sp-icon-checkmark-circle';
defaultLabel = 'Success';
break;
default:
iconType = '';
defaultLabel = '';
break;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of this can be simplified via class="type" being on the icon element. The rest of the data feels like it should be externalized some how, but I don't have a good suggestion on cleaning it up just now. Maybe an map of some sort outside of the test case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Issues related to accessibility Component: Toast
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug][a11y]: Toast should have API for overriding the icon's alt text
6 participants