fix(suggestion-group): update suggestion group heading semantics#6224
fix(suggestion-group): update suggestion group heading semantics#6224TarunAdobe wants to merge 3 commits into
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
| const fallbackLabel = | ||
| this.accessibleLabel.trim().length > 0 | ||
| ? this.accessibleLabel.trim() | ||
| : 'Follow-up suggestions'; |
There was a problem hiding this comment.
i can do a follow up PR converting this logic into a shared util for all components if possible :)
| [ | ||
| 'Accordion', | ||
| [ | ||
| 'Accessibility migration analysis', | ||
| 'Rendering and styling migration analysis', | ||
| ], | ||
| 'Action button', |
There was a problem hiding this comment.
this is coming after recent merge of accordion to main???! not sure do we wanna fix it here or i remove it?
74c5186 to
c409178
Compare
c409178 to
548603f
Compare
| ${text} | ||
| </h3> | ||
| `; | ||
| private _getHeadingElement(): HTMLElement | null { |
There was a problem hiding this comment.
do we really need this function? we could literally just read this._assignedHeadingElements[0] wherever
|
|
||
| protected override updated(_changedProperties: PropertyValues<this>): void { | ||
| super.updated(_changedProperties); | ||
| this._ensureHeadingId(); |
There was a problem hiding this comment.
do we need this here? the slotchangehandler is already doing this. we could prob get rid of the function then
| const accessibleLabel = this.accessibleLabel.trim(); | ||
| const hasAccessibleLabel = accessibleLabel.length > 0; | ||
|
|
||
| if (!hasHeading && !hasAccessibleLabel) { |
There was a problem hiding this comment.
hmmm, this is interesting. rn you're running this after ensureHeadingId so this is always true. Depending on your refactor from the other comments, please check.
| hasHeading ? 'swc-suggestion-group-heading' : undefined | ||
| )} | ||
| > | ||
| <div class="swc-SuggestionGroup-title" ?hidden=${!hasHeading}> |
There was a problem hiding this comment.
hmmm this is not great... on the first render hasHeading is false and the title div gets hidden. Then updated() triggers a second render that flips it, this is probably gonna cause some flash... you can either skip the ?hidden binding and use CSS to handle the no-heading case instead (e.g. :empty)
There was a problem hiding this comment.
This is a double paint. Good catch!
| 'parent exposes heading and group labeling on the host (not inner shadow nodes)', | ||
| async () => { | ||
| await group.updateComplete; | ||
| await Promise.resolve(); |
There was a problem hiding this comment.
what is this? updateComplete, resolve, updatecomplete? 😅
| this._ensureHeadingId(); | ||
| this._syncHostGroupSemantics(); |
There was a problem hiding this comment.
This runs on every update. Put a guard
fix(suggestion-group): require heading slot and prioritize accessible-label
Description
This PR updates suggestion group semantics and accessibility behavior:
slot="heading"instead of fixed internal heading semantics.accessible-labelthe accessible-name override when provided.Motivation and context
We want suggestion group to behave as a true composition primitive:
This avoids hardcoded semantics and prevents component styles from overriding consumer heading intent.
Related issue(s)
Screenshots (if appropriate)
N/A (behavioral/API and docs-focused change)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Heading semantics are consumer-controlled
Conversational AI / Suggestion group / Heading.h3andh2inslot="heading".Accessible label precedence over heading
accessible-label="Custom suggestions label".aria-label="Custom suggestions label"and not use heading-based labeling.No forced heading typography from component
Conversational AI / Suggestion group / Heading.Related conversational usage remains stable
Conversational AI / System message / PlaygroundConversational AI / Conversation thread / PlaygroundDevice review
Accessibility testing checklist
Keyboard (required — document steps below) — What to test for: Focus order is logical; Tab reaches the component and all interactive descendants; Enter/Space activate where appropriate; arrow keys work for tabs, menus, sliders, etc.; no focus traps; Escape dismisses when applicable; focus indicator is visible.
Conversational AI / Suggestion group / Overview.Screen reader (required — document steps below) — What to test for: Role and name are announced correctly; state changes (e.g. expanded, selected) are announced; labels and relationships are clear; no unnecessary or duplicate announcements.
Conversational AI / Suggestion group / Accessibility.accessible-label.accessible-labelwhen present.