Skip to content

Fix aria-pressed initialization for toggle buttons#42466

Open
puneetdixit200 wants to merge 1 commit into
twbs:mainfrom
puneetdixit200:fix-button-aria-pressed-init
Open

Fix aria-pressed initialization for toggle buttons#42466
puneetdixit200 wants to merge 1 commit into
twbs:mainfrom
puneetdixit200:fix-button-aria-pressed-init

Conversation

@puneetdixit200
Copy link
Copy Markdown

Description

Initializes missing aria-pressed on button plugin instances from the current .active state. Inactive toggle buttons now get aria-pressed="false", and already-active toggle buttons get aria-pressed="true" when the attribute was not present in the markup.

Motivation & Context

Fixes #42328.

The button plugin already keeps aria-pressed in sync when toggling. This covers the initial state so assistive technologies can identify the button as a toggle before the first click.

Type 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)
  • Documentation update

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (npm run js-lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Tests

  • Red check: npm_config_cache=/tmp/bootstrap-42328-npm-cache npm run js-test-karma failed before the implementation with the new test seeing aria-pressed as null.
  • Green check: npm_config_cache=/tmp/bootstrap-42328-npm-cache npm run js-test-karma reported 810/810 successful tests and exited 0. Karma also printed its existing full-page-reload shutdown warning.
  • npm_config_cache=/tmp/bootstrap-42328-npm-cache npm run js-lint exited 0, with existing warning-comment warnings in unrelated files.
  • git diff --check

AI assistance was used for implementation and verification. I reviewed the code and test results before submitting.

@puneetdixit200 puneetdixit200 requested a review from a team as a code owner June 4, 2026 03:34
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.

Missing aria-pressed="false" at toggle buttons initialization (button plugin)

1 participant