fix(framework): component children that are slots now invalidate parent upon slotchange #1649
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.
There are composition scenarios where a component, say
ui5-upload-collection
creates aui5-list
in its shadow root and slots all its children to the list transitively by just rendering aslot
in the list.Example:
The problem with this is that the framework will only invalidate the
ui5-list
whenever its children are added/removed, but in this case the only child is the slot and it is completely static. Yet, when the user adds items to theui5-upload-collection
, they will be rendered transitively by the list, but the list will not be updated. Therefore some of the children may not be displayed properly.The reported issue is that when you add items to the upload collection in "Delete" mode, the new items don't get a "Delete" button until the list is invalidated by something else.
Therefore, this change adds some extra capabilities for components with
managedSlots: true
. If they have<slot>
children, these will haveslotchange
attached/detached automatically by the framework, and the parent component, in this exampleui5-list
will be invalidated whenever theslotchange
event is fired, which is upon adding/removing elements to the slot.In the future, this may be easily enhanced to work recursively by doing the same for slots inside slots, but for the time being this might not be necessary.
Additionally, a new
isSlot
utility is added to check if a Node is slot.Additionally,
ui5-input
was changed to use thegetSlottedNodes
function, already provided byUI5Element.js
instead of re-implementing it, to easily get the list of all slotted children in thevalueStateMessage
slot.This change will affect several components:
ui5-upload-collection
,ui5-tree
,ui5-datepicker
, etc... mostly components that transitively slot content to the input or list.fixes: #1647