Repository navigation
fix(aria/accordion): update panel visibility when the trigger links after first render - #34198
Open
DuncanFaulkner wants to merge 1 commit into
Open
DuncanFaulkner wants to merge 1 commit into
DuncanFaulkner wants to merge 1 commit into
Conversation
crisbeto
reviewed
Nov 30, 2026
| * This is set by the trigger when it initializes. | ||
| * There is no need for a panel pattern, as the trigger has all the necessary logic. | ||
| */ | ||
| _pattern?: AccordionTriggerPattern; |
Member
There was a problem hiding this comment.
This is with an underscore so it doesn't need to be backwards compatible. We can just expose the _triggerPattern.
Contributor
Author
There was a problem hiding this comment.
Thanks, done. The panel's _pattern is now a _triggerPattern signal that the trigger sets directly, and the getter/setter is gone. The specs and the API golden are updated to match.
…fter first render Since angular#34061, `AccordionTrigger` links itself to its panel inside an effect, which can run after the panel's first render. `AccordionPanel.visible` is a computed over `_pattern`, which was a plain field. If anything reads `visible()` before the trigger links (for example a template binding such as `[class.hidden]="!panel.visible()"`), the computed caches `false` with no reactive dependencies and never re-evaluates. The panel's own `[attr.inert]` host binding reads the same computed, so the panel stays hidden and inert even though the trigger reports `aria-expanded="true"`. The panel's `_pattern` field is replaced by a `_triggerPattern` signal that the trigger sets, so `visible()` updates when the trigger links or unlinks the panel.
DuncanFaulkner
force-pushed
the
fix/aria-accordion-panel-visible
branch
from
November 30, 2026 09:16
d1899b1 to
3e2574a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since #34061,
AccordionTriggerlinks itself to its panel (panel._pattern = this._pattern) inside aneffect, which can run after the panel's first render.AccordionPanel.visibleis acomputedover_pattern, and_patternwas a plain field. If anything readsvisible()before the trigger has linked the panel, the computed cachesfalsewith no reactive dependencies and never re-evaluates.A template that styles the panel from its public
visible()signal is enough to hit this:With
@angular/aria22.2.7 and 22.3.0, clicking the trigger setsaria-expanded="true", butvisible()staysfalse, so the panel keeps the class and the panel's own[attr.inert]host binding (which reads the same computed) keeps itinert. The content is unreachable by keyboard and screen reader even though the trigger says it is expanded. The documented markup without a template read ofvisible()is not affected. It worked in 22.2.6 and earlier, when the link was made before the first render.We hit this in a component library that hides the panel with
[class.x]="!panel.visible()": every section stayed closed for anyone on the latest@angular/aria.Fix
The panel's
_patternfield is replaced by a_triggerPatternsignal. The trigger sets it when it links or unlinks the panel, and the panel'svisible, host bindings,expand()/collapse()/toggle()and dev-mode checks read it. The trigger's ownership check reads the signal directly instead of casting toany.Tests
New spec
AccordionPanel visibility > should update visible() when a template reads it before the trigger links the panel: a panel with[class.is-hidden]="!panel.visible()"is expanded and collapsed through the trigger, checking the class,inert,aria-expanded,aria-labelledbyand the rendered content.Validation
//src/aria/accordion:unit_tests(chromium and firefox) pass with the fix. With the previousaccordion-panel.ts, the new spec fails in both browsers (Expected is-hidden not to contain 'is-hidden').describeand added thearia-expanded/aria-labelledbyassertions; those last edits are verified by this PR's CI.goldens/aria/accordion/index.api.md) is updated by hand;//goldens:aria_apiruns in CI.