Skip to content

refactor(aria/tabs): clean up tab selection and linking to panels#32859

Open
adolgachev wants to merge 1 commit intoangular:mainfrom
adolgachev:aria-tabs
Open

refactor(aria/tabs): clean up tab selection and linking to panels#32859
adolgachev wants to merge 1 commit intoangular:mainfrom
adolgachev:aria-tabs

Conversation

@adolgachev
Copy link
Copy Markdown
Contributor

@adolgachev adolgachev commented Feb 26, 2026

Refactors Tabs pattern to simplify how tabs are associated with their tab panels, as well as other dependent code.

This is a revision of the previous approach which swapped to use contentChildren and template references only

This just includes clean up and re-factoring to move the value matching of Tab and TabPanel to the directive and remove extra synching of selection and linked state in favor of a more direct approach.

@adolgachev adolgachev changed the title Aria tabs refactor(aria/tabs): Rework to use template reference to link tabs and panels Feb 26, 2026
@adolgachev adolgachev added Accessibility This issue is related to accessibility (a11y) dev-app preview When applied, previews of the dev-app are deployed to Firebase docs: preview When applied, a preview of the documentation site is deployed to Firebase labels Feb 26, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 26, 2026

Deployed dev-app for d0613b3 to: https://ng-dev-previews-comp--pr-angular-components-32859-dev-pxtvzh2b.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 26, 2026

Deployed docs-preview for d0613b3 to: https://ng-dev-previews-comp--pr-angular-components-32859-docs-58cy5tjn.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@adolgachev adolgachev force-pushed the aria-tabs branch 6 times, most recently from 9f18364 to cb3c051 Compare March 7, 2026 01:49
@adolgachev adolgachev changed the title refactor(aria/tabs): Rework to use template reference to link tabs and panels refactor(aria/tabs): simplify code by using template references instead of user id to link tabs and panels Mar 7, 2026
@adolgachev adolgachev force-pushed the aria-tabs branch 7 times, most recently from f6c32a1 to d913ebb Compare March 11, 2026 05:29
@adolgachev adolgachev marked this pull request as ready for review March 11, 2026 05:36
@adolgachev adolgachev requested a review from ok7sai March 11, 2026 05:36
@pullapprove pullapprove Bot requested review from andrewseguin and tjshiu March 11, 2026 05:36
@adolgachev adolgachev added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 11, 2026
@adolgachev adolgachev marked this pull request as draft March 12, 2026 00:24
@adolgachev adolgachev added the target: patch This PR is targeted for the next patch release label Mar 12, 2026
@adolgachev adolgachev marked this pull request as ready for review March 12, 2026 19:55
@adolgachev adolgachev force-pushed the aria-tabs branch 2 times, most recently from be451be to 45041c5 Compare March 19, 2026 21:50
@adolgachev adolgachev force-pushed the aria-tabs branch 2 times, most recently from fd5f0bb to 96f2cbb Compare April 1, 2026 23:43
@adolgachev adolgachev force-pushed the aria-tabs branch 3 times, most recently from 54ee045 to fa930ac Compare April 15, 2026 00:20
@adolgachev adolgachev changed the title refactor(aria/tabs): simplify code by using template references instead of user id to link tabs and panels refactor(aria/tabs): clean up tab selection and linking to panels, add direct template ref Apr 15, 2026
@adolgachev adolgachev force-pushed the aria-tabs branch 2 times, most recently from c687368 to b914539 Compare April 15, 2026 23:08
@ok7sai
Copy link
Copy Markdown
Member

ok7sai commented Apr 15, 2026

We should put this change on hold for two main reasons

  • Static Id assignment is discouraged internally.
  • Unlike Accordion that a trigger-panel pair are strongly coupled in the document, tabs and panels are two separated groups so the template reference passing can easily fail due to the scoping issue. A common use case we've seen is the tablist gets wrapped into a standalone component.

value input might no be the cleanest implementation, but I also don't see a big drawback of it.

@adolgachev adolgachev force-pushed the aria-tabs branch 2 times, most recently from 374f2c5 to 2de91db Compare April 21, 2026 05:51
@adolgachev adolgachev added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Apr 21, 2026
@adolgachev adolgachev changed the title refactor(aria/tabs): clean up tab selection and linking to panels, add direct template ref refactor(aria/tabs): clean up tab selection and linking to panels Apr 21, 2026
@pullapprove pullapprove Bot requested a review from wagnermaciel April 21, 2026 07:29
@adolgachev adolgachev removed the request for review from wagnermaciel April 21, 2026 07:30
@pullapprove pullapprove Bot requested a review from wagnermaciel April 21, 2026 07:30
Comment thread src/aria/tabs/tab-list.ts Outdated
Comment thread src/aria/tabs/tabs.spec.ts Outdated
Comment thread src/aria/tabs/tabs.ts Outdated
[...this._unorderedPanels()].map(tabpanel => tabpanel._pattern),
);
constructor() {
effect(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use afterRenderEffect as discussed. Same comment for other places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, in the other place it actually shows up as a bug with the Scrollable example. Added comments too.

Comment thread src/aria/tabs/tab-list.ts Outdated
readonly selectedTab = model<string | undefined>();

/** The current selected Tab pattern, passed to the List pattern. */
private readonly _selectedTabPattern: WritableSignal<TabPattern | undefined> = signal(undefined);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can probably be a linkedSignal instead of computed in effect?

Copy link
Copy Markdown
Contributor Author

@adolgachev adolgachev Apr 21, 2026

Choose a reason for hiding this comment

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

That actually did not work... let me try to put it back to test again and add a comment why though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cool, it is actually working now. It may have just been an issue with the full PR. But tested local tests and with browserstack to make sure and looks good.

@adolgachev adolgachev force-pushed the aria-tabs branch 3 times, most recently from 94cfe7e to 91dce82 Compare April 21, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accessibility This issue is related to accessibility (a11y) action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer area: aria/tabs dev-app preview When applied, previews of the dev-app are deployed to Firebase docs: preview When applied, a preview of the documentation site is deployed to Firebase target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants