[KZN-4067]: expose ref on Collapsible - #6821
Open
AliceMenzie wants to merge 3 commits into
Open
Conversation
Contributor
🤖 Agent Workflows
|
🦋 Changeset detectedLatest commit: 2982805 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Wraps Collapsible in forwardRef, forwarding to the toggle IconButton via
useImperativeHandle. Exposes ButtonRef ({ focus }) so consumers can
programmatically focus the toggle after async operations — replacing
fragile querySelector workarounds.
Also exports ButtonRef from the ButtonV1 barrel so consumers can type
their refs without reaching into internals.
Closes KZN-4067
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AliceMenzie
force-pushed
the
am/KZN-4067-collapsible-ref
branch
from
June 23, 2026 05:05
c13cfff to
484cf48
Compare
Define CollapsibleRef = { focus: () => void } in Collapsible itself so
the public API has no dependency on ButtonV1 internals. The
useImperativeHandle factory now constructs the object directly rather
than forwarding the internal ButtonRef.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
CollapsibleinforwardRef, forwarding the ref to the toggleIconButtonviauseImperativeHandleButtonRefinterface ({ focus: () => void }) so consumers can programmatically focus the toggle buttonButtonReftype from theCollapsibleindex for convenienceContext
Requested in KZN-4067. The consumer (
probations-reviews-ui) needed to restore focus to the Collapsible toggle button after async operations (save/delete in a sortable list) and was working around this with a fragilequerySelector('[data-testid="collapsible-button-..."]').Usage
Test plan
WithProgrammaticFocusdemonstrates the async focus flow🤖 Generated with Claude Code