Skip to content

Add scope attribute support for table headers #7853

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Add scope attribute support for table headers #7853

wants to merge 2 commits into from

Conversation

djhvscf
Copy link
Collaborator

@djhvscf djhvscf commented May 24, 2025

Preserve and render the 'scope' attribute from th elements to improve table accessibility for screen readers.

🤔Type of Request

  • Bug fix
  • New feature
  • Improvement
  • Documentation
  • Other

🔗Resolves an issue?
Fix #7780

📝Changelog

  • Core
  • Extensions

💡Example(s)?
https://live.bootstrap-table.com/code/djhvscf/18817

☑️Self Check before Merge

⚠️ Please check all items below before reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

Preserve and render the 'scope' attribute from th elements to improve table accessibility for screen readers.
@djhvscf djhvscf requested review from Copilot and wenzhixin May 24, 2025 01:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for preserving and rendering the scope attribute on <th> elements to improve table accessibility.

  • Extracts scope from header <th> attributes into column configuration
  • Includes scope when generating header cell HTML
Comments suppressed due to low confidence (1)

src/bootstrap-table.js:201

  • [nitpick] The new scope option should be documented in the public API docs or JSDoc comments so consumers know this attribute is now supported.
scope: $th.attr('scope'),

Comment on lines 374 to +375
Utils.sprintf(' data-field="%s"', column.field),
Utils.sprintf(' scope="%s"', column.scope),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Utils.sprintf(' data-field="%s"', column.field),
Utils.sprintf(' scope="%s"', column.scope),
Utils.sprintf(' scope="%s"', column.scope),
Utils.sprintf(' data-field="%s"', column.field),

Comment on lines +201 to 203
scope: $th.attr('scope') ? $th.attr('scope') : undefined,
rowspan: $th.attr('rowspan') ? +$th.attr('rowspan') : undefined,
colspan: $th.attr('colspan') ? +$th.attr('colspan') : undefined
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
scope: $th.attr('scope') ? $th.attr('scope') : undefined,
rowspan: $th.attr('rowspan') ? +$th.attr('rowspan') : undefined,
colspan: $th.attr('colspan') ? +$th.attr('colspan') : undefined
rowspan: $th.attr('rowspan') ? +$th.attr('rowspan') : undefined,
colspan: $th.attr('colspan') ? +$th.attr('colspan') : undefined,
scope: $th.attr('scope') ? $th.attr('scope') : undefined

Copy link
Owner

Choose a reason for hiding this comment

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

Suggest keeping the same order.

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.

Scope attribute stripped from th elements when sorting is active
2 participants