-
Notifications
You must be signed in to change notification settings - Fork 235
refactor(overlay): leverage "reparentChildren" helper #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| return function () { | ||
| restoreChildren(placeholderItems, srcElements); | ||
| return function (): Element[] { | ||
| return restoreChildren(placeholderItems, srcElements, slotNames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use return so that consumers that want to do something more with the elements after their return can.
| 'placement', | ||
| this.originalPlacement | ||
| ); | ||
| element.setAttribute('placement', this.originalPlacement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is managed here, and slot is managed there... it begs a question should the API be:
reparentChildren(Element[], Element, () => () => void);
Where the double callback at the end amount to prepare and cleanup functionality?
In this way, slot wouldn't have to be managed on everything, and placement or whatever else came up over time, wouldn't have to be cached in the originating code location.
Everything could just be managed/cached at the originating location, just the same, but want to make the workflow clear as one of the follow up tasks to the overall refactor here will be to add this method to: https://opensource.adobe.com/spectrum-web-components/components/shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR removed the naming of the slot for this element, but the final workflow here would have needed to support the management of the value as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the callbacks would be optional -- definitely makes sense to add more control to the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check it out in #1310
bb81dd6 to
1a76372
Compare
1f67e10 to
1f9e14b
Compare
1f9e14b to
bfda092
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
| 'placement', | ||
| this.originalPlacement | ||
| ); | ||
| element.setAttribute('placement', this.originalPlacement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the callbacks would be optional -- definitely makes sense to add more control to the API.
|
|
||
| public menuItems: MenuItem[] = []; | ||
| private restoreChildren?: Function; | ||
| private restoreChildren?: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh -- still learning typescript here. This makes sense to me.
bfda092 to
3445446
Compare
Description
Use the
reparentChildrenhelper inoverlay-trigger.Related Issue
fixes #1249
Motivation and Context
Simplify code by leveraging helper.
How Has This Been Tested?
CI.
Types of changes
Checklist: