Repository navigation
fix(button): resolve commandfor only when connected - #2592
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change still has an active documentation issue because the component spec does not describe the newly supported reconnect and detached-attribute lifecycle behavior.
1 open issue
What changed in this PR
Fixes commandfor resolution for buttons configured while detached by deferring target lookup until connection and re-resolving targets after detached changes or reconnection.
Changes:
- Defers detached
commandforlookups untilconnectedCallback. - Re-resolves command targets when
commandforchanges while detached. - Adds regression tests and an Unreleased changelog entry.
| File | Description |
|---|---|
| src/components/button/button.spec.ts | Adds regression tests for commandfor configured before insertion and changed while the button is detached. |
| src/components/button/button-base.ts | Guards detached target lookups and resolves the commandfor target when the component connects. |
| CHANGELOG.md | Documents the detached-button commandfor fix under Unreleased. |
Review effort: Lite
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
rkaraivanov
approved these changes
Nov 12, 2026
6 tasks done
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.

Description
Setting
commandforon a detachedigc-buttonorigc-icon-buttonthrewgetElementById is not a function: a detached element is its own root node, and elements have nogetElementById. Frameworks that set attributes before inserting an element hit this whenever the button is already defined, for example Blazor rendering<IgbButton Commandfor="...">on a page visited a second time.The setter now looks up the target only while connected, and
connectedCallbackresolves it on attach. This also applies acommandforchanged while detached, which used to keep the previous target once the button was attached again.Type of Change
Testing
Button spec:
commandforset before the button is inserted, and changed while it is detached. Both fail onmasterwith the error above.Checklist
CHANGELOG.mdentry under[Unreleased]🤖 Generated with Claude Code