Skip to content

RC #365#366

Merged
rmenner merged 2 commits into
mainfrom
rc/365
Oct 9, 2025
Merged

RC #365#366
rmenner merged 2 commits into
mainfrom
rc/365

Conversation

@rmenner

@rmenner rmenner commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Alaska Airlines Pull Request

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

Summary by Sourcery

Enable slot-based ARIA labeling for auro-button, deprecate the loadingText property, and update code, documentation, demos, and tests to reflect the new slot API

New Features:

  • Introduce ariaLabel and ariaLabel.loading slots for passing accessible labels and loading labels to auro-button
  • Add support for the aria-labelledby attribute on auro-button

Enhancements:

  • Deprecate loadingText attribute in favor of slot-based ariaLabel.loading usage
  • Refactor auro-button to render hidden ariaLabel slots and compute aria-label with generateAriaLabel()
  • Update demos, API docs, and examples to replace arialabel attributes with slot-based ARIA labels
  • Bump @aurodesignsystem/auro-library dev dependency to v5.5.4

Documentation:

  • Restructure ARIA support section and update headings in API documentation

Tests:

  • Add tests for setting aria-label via ariaLabel and ariaLabel.loading slots

@rmenner
rmenner requested a review from a team as a code owner October 9, 2025 17:33
@sourcery-ai

sourcery-ai Bot commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR refactors aria-label support in the AuroButton component by introducing dedicated slots for default and loading state labels (deprecating the loadingText property), updates documentation and examples to use the new slot-based API, enhances tests to cover these changes, bumps the auro-library dependency, and removes an outdated demo script.

Class diagram for updated AuroButton aria-label logic

classDiagram
  class AuroButton {
    +slot ariaLabel
    +slot ariaLabel.loading
    -loadingText : String (deprecated)
    +generateAriaLabel() : String
    -currentAriaLabel : String
    -currentAriaLabelledBy : String
  }
  AuroButton --> "1" runtimeUtils : uses
  class runtimeUtils {
    +getSlotText(element, slotName) : String
    +handleComponentTagRename(element, tagName)
  }
Loading

Class diagram for deprecated loadingText property

classDiagram
  class AuroButton {
    -loadingText : String (deprecated)
  }
Loading

File-Level Changes

Change Details Files
Accessibility overhaul: slot-based aria-label support and loadingText deprecation
  • Added ariaLabel and ariaLabel.loading slots in component API
  • Deprecated loadingText property and docs
  • Introduced generateAriaLabel() for dynamic aria-label resolution
  • Updated template to render hidden slots and use generateAriaLabel()
src/auro-button.js
Docs & examples updated for ariaLabel slots
  • Replaced arialabel attributes with slot usage across demos and docs
  • Updated headings and section titles to match new API
  • Added new example files for ariaLabel and ariaLabelledby
  • Removed loadingText-based examples
demo/api.md
demo/index.md
docs/partials/api.md
docs/api.md
apiExamples/icon.html
apiExamples/shape-circle.html
apiExamples/shape-square.html
apiExamples/static.html
apiExamples/roundedRightAlign.html
apiExamples/roundedTextOnly.html
apiExamples/roundedTextWithIcon.html
apiExamples/toggledText.html
apiExamples/ariaLabel.html
apiExamples/ariaLabelledby.html
Tests enhanced for slot-based aria-labels
  • Renamed existing aria-label test for clarity
  • Added test for ariaLabel slot support
  • Added test for ariaLabel.loading slot in loading state
  • Adjusted default loading aria-label expectation
test/auro-button.test.js
Dependency update
  • Bumped @aurodesignsystem/auro-library from ^5.5.3 to ^5.5.4
package.json
Demo cleanup
  • Removed obsolete auro-formkit script include
demo/api.html

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider adding a console warning or fallback to catch buttons without any ariaLabel slot or attribute to prevent accidental accessibility regressions.
  • The bulk update of example files could be streamlined by centralizing snippet templates or using a shared include mechanism to reduce future maintenance overhead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a console warning or fallback to catch buttons without any ariaLabel slot or attribute to prevent accidental accessibility regressions.
- The bulk update of example files could be streamlined by centralizing snippet templates or using a shared include mechanism to reduce future maintenance overhead.

## Individual Comments

### Comment 1
<location> `src/auro-button.js:29-35` </location>
<code_context>

 /**
  * @slot - Default slot for the text of the button.
+ * @slot ariaLabel - Use this slot to pass an aria-label to the HTML5 button.
+ * @slot ariaLabel.loading - Use this slot to pass an aria-label to the HTML5 button when in loading state.
  * @csspart button - Apply CSS to HTML5 button.
  * @csspart loader - Apply CSS to auro-loader.
</code_context>

<issue_to_address>
**suggestion:** Consider clarifying slot usage for aria-labels in documentation.

Specify in the documentation that only plain text should be used in these slots for aria-labels, without interactive elements or markup, to ensure proper accessibility.

```suggestion
/**
 * @slot - Default slot for the text of the button.
 * @slot ariaLabel - Use this slot to pass an aria-label (plain text only, no markup or interactive elements) to the HTML5 button for accessibility.
 * @slot ariaLabel.loading - Use this slot to pass an aria-label (plain text only, no markup or interactive elements) to the HTML5 button when in loading state for accessibility.
 * @csspart button - Apply CSS to HTML5 button.
 * @csspart loader - Apply CSS to auro-loader.
 * @csspart text - Apply CSS to text slot.
```
</issue_to_address>

### Comment 2
<location> `test/auro-button.test.js:137-149` </location>
<code_context>
     expect(button.getAttribute("aria-label")).to.equal("label");
   });

+    it("tests setting aria-label via slot", async () => {
+    const el = await fixture(html`
+      <auro-button>
+        <span slot="ariaLabel">label</span>
+        Click Me!
+      </auro-button>
+    `);
+
+    const root = el.shadowRoot;
+    const button = root.querySelector("button");
+
+    expect(button.getAttribute("aria-label")).to.equal("label");
+  });
+
</code_context>

<issue_to_address>
**suggestion (testing):** Consider adding a test for multiple ariaLabel slots or conflicting sources.

Please add a test where both the aria-label attribute and ariaLabel slot are set, to confirm which value is used.

```suggestion
    it("tests setting aria-label via slot", async () => {
    const el = await fixture(html`
      <auro-button>
        <span slot="ariaLabel">label</span>
        Click Me!
      </auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("label");
  });

  it("tests aria-label precedence: slot vs attribute", async () => {
    const el = await fixture(html`
      <auro-button aria-label="attributeLabel">
        <span slot="ariaLabel">slotLabel</span>
        Click Me!
      </auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    // Expect slot to take precedence over attribute
    expect(button.getAttribute("aria-label")).to.equal("slotLabel");
  });
```
</issue_to_address>

### Comment 3
<location> `test/auro-button.test.js:173-184` </location>
<code_context>
     expect(button.getAttribute("aria-label")).to.equal(el.loadingText);
   });

+  it("tests setting custom loading text on button in loading state via slot", async () => {
+    const el = await fixture(html`
+      <auro-button loading>
+        <span slot="ariaLabel.loading">Cargando...</span>
+      </auro-button>
+    `);
+
+    const root = el.shadowRoot;
+    const button = root.querySelector("button");
+
+    expect(button.getAttribute("aria-label")).to.equal("Cargando...");
+  });
+
</code_context>

<issue_to_address>
**suggestion (testing):** Add a test for fallback behavior when ariaLabel.loading slot is empty or missing.

Add a test to verify that when the ariaLabel.loading slot is empty or missing, the button correctly falls back to loadingText or the default 'Loading...'.

```suggestion
  it("tests setting custom loading text on button in loading state via slot", async () => {
    const el = await fixture(html`
      <auro-button loading>
        <span slot="ariaLabel.loading">Cargando...</span>
      </auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("Cargando...");
  });

  it("falls back to loadingText when ariaLabel.loading slot is missing", async () => {
    const el = await fixture(html`
      <auro-button loading loadingText="Cargando">Click Me!</auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("Cargando");
  });

  it("falls back to loadingText when ariaLabel.loading slot is empty", async () => {
    const el = await fixture(html`
      <auro-button loading loadingText="Cargando">
        <span slot="ariaLabel.loading"></span>
      </auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("Cargando");
  });

  it("falls back to default 'Loading...' when ariaLabel.loading slot and loadingText are missing", async () => {
    const el = await fixture(html`
      <auro-button loading>Click Me!</auro-button>
    `);

    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("Loading...");
  });
```
</issue_to_address>

### Comment 4
<location> `test/auro-button.test.js:156-160` </location>
<code_context>
+    expect(button.getAttribute("aria-label")).to.equal("label");
+  });
+
   it("tests that button in loading state has proper aria-label", async () => {
     const el = await fixture(html`
       <auro-button loading>Click Me!</auro-button>
</code_context>

<issue_to_address>
**suggestion (testing):** Consider testing for dynamic changes to loading state and aria-label.

Add a test that toggles the loading state after render to confirm the aria-label updates as expected.

```suggestion
  it("tests that button in loading state has proper aria-label", async () => {
    const el = await fixture(html`
      <auro-button loading>Click Me!</auro-button>
    `);
    const root = el.shadowRoot;
    const button = root.querySelector("button");

    expect(button.getAttribute("aria-label")).to.equal("Loading...");
  });

  it("tests dynamic changes to loading state update aria-label", async () => {
    const el = await fixture(html`
      <auro-button aria-label="label">Click Me!</auro-button>
    `);
    const root = el.shadowRoot;
    const button = root.querySelector("button");

    // Initial state
    expect(button.getAttribute("aria-label")).to.equal("label");

    // Toggle loading on
    el.loading = true;
    await el.updateComplete;
    expect(button.getAttribute("aria-label")).to.equal("Loading...");

    // Toggle loading off
    el.loading = false;
    await el.updateComplete;
    expect(button.getAttribute("aria-label")).to.equal("label");
  });
```
</issue_to_address>

### Comment 5
<location> `demo/api.md:496` </location>
<code_context>
-#### Right Aligned
+## Right Aligned

 This example shows a `rounded` `auro-button` that is right-aligned, demonstrating how the button starts from the right and grows/shrinks from right to left when using the `toggleText` attribute in conjuction with the `mouseover` and `mouseout` events. The `focusin` and `focusout` events simulate toggling text for keyboard users.

</code_context>

<issue_to_address>
**issue (typo):** Typo: 'conjuction' should be 'conjunction'.

Update the sentence to use the correct spelling: 'conjunction'.

```suggestion
This example shows a `rounded` `auro-button` that is right-aligned, demonstrating how the button starts from the right and grows/shrinks from right to left when using the `toggleText` attribute in conjunction with the `mouseover` and `mouseout` events. The `focusin` and `focusout` events simulate toggling text for keyboard users.
```
</issue_to_address>

### Comment 6
<location> `docs/partials/api.md:186` </location>
<code_context>
-#### Right Aligned
+## Right Aligned

 This example shows a `rounded` `auro-button` that is right-aligned, demonstrating how the button starts from the right and grows/shrinks from right to left when using the `toggleText` attribute in conjuction with the `mouseover` and `mouseout` events. The `focusin` and `focusout` events simulate toggling text for keyboard users.

</code_context>

<issue_to_address>
**issue (typo):** Typo: 'conjuction' should be 'conjunction'.

Please update the spelling to 'conjunction'.

```suggestion
This example shows a `rounded` `auro-button` that is right-aligned, demonstrating how the button starts from the right and grows/shrinks from right to left when using the `toggleText` attribute in conjunction with the `mouseover` and `mouseout` events. The `focusin` and `focusout` events simulate toggling text for keyboard users.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/auro-button.js
@rmenner
rmenner merged commit a68d36d into main Oct 9, 2025
19 of 20 checks passed
@rmenner
rmenner deleted the rc/365 branch October 9, 2025 17:35
@github-actions

github-actions Bot commented Oct 9, 2025

Copy link
Copy Markdown

🎉 This PR is included in version 12.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released Completed work has been released label Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Completed work has been released semantic-status: feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants