Repository navigation
fix: release removed node in single-mode slot controller - #13158
Conversation
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 1 comment and collected 1 finding below that could not be attached to the diff.
| Finding | |
|---|---|
| 📝 | TypeScript definitions still declare node and _labelNode as non-nullable |
| 🧪 | New _labelNode null paths in checkbox have no test |
📝 TypeScript definitions still declare node and _labelNode as non-nullable
SlotController.node is typed HTMLElement, and LabelMixin._labelNode (packages/field-base/src/label-mixin.d.ts:20) as HTMLLabelElement. Both can now be null — the JS side of this PR acknowledges that by adding ?. in checkbox and crud. TS consumers (including Flow components and anyone subclassing SlotController) get no warning for controller.node.textContent after the slotted node is removed.
slot-controller.d.ts:17 · documentation
| target === this.inputElement || | ||
| target.part.contains('required-indicator') || | ||
| (this._labelNode.contains(target) && !target.closest('a')); | ||
| (this._labelNode?.contains(target) && !target.closest('a')); |
There was a problem hiding this comment.
🧪 New _labelNode null paths in checkbox have no test
Removing a custom <label slot="label"> from a checkbox with no label property now leaves _labelNode as null permanently, since restoreDefaultNode only attaches a default when label is non-empty. Without the ?. in _shouldSetActive, every pointerdown on that checkbox throws. Nothing in packages/checkbox/test removes the slotted label, so dropping either guard later would go unnoticed.
vaadin-checkbox-mixin.js:134 · tests
There was a problem hiding this comment.
Added a test to verify the clicking helper node after removing custom label does not throw.
dae2845 to
5161810
Compare
In single mode, removing the slotted node kept it as `node`, so adding the same node back was ignored and teardown wrote default content into the removed custom node. Guard checkbox and crud reads of the now nullable node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5161810 to
c5c1ec5
Compare
Updated typings accordingly. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
This ticket/PR has been released with Vaadin 25.4.0-alpha4. |



Description
Related to #13157
In single mode,
SlotControllerkept a removed slotted node asnode. Adding the same node back was then ignored, andSlotChildObserveController.teardownNode()passed the removed custom node toupdateDefaultNode(), which overwrote its content.SlotControllerto resetnodetonullin single mode when the current node is removednodesis no longer set in single modeslot="label"andslot="helper"content being cleared on removal whenlabel/helperTextis emptyvaadin-tooltip(nohas-tooltip, no target) and TabSheetvaadin-tabs_labelNodeand crud_headerNodereads, which can now benullSlotController,TooltipControllerandLabelMixintestsType of change
How to test
dev/text-field.html<label slot="label">Custom</label>to avaadin-text-fieldwithoutlabeltextContentCustom, not empty🤖 Generated with Claude Code