Skip to content

Conversation

@Westbrook
Copy link
Contributor

Description

Use the reparentChildren helper in overlay-trigger.

Related Issue

fixes #1249

Motivation and Context

Simplify code by leveraging helper.

How Has This Been Tested?

CI.

Types of changes

  • Refactor

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Westbrook Westbrook requested a review from adixon-adobe March 12, 2021 18:03
@Westbrook Westbrook marked this pull request as draft March 12, 2021 18:04
return function () {
restoreChildren(placeholderItems, srcElements);
return function (): Element[] {
return restoreChildren(placeholderItems, srcElements, slotNames);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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

@Westbrook Westbrook force-pushed the westbrook/overlay-reparenting branch from bb81dd6 to 1a76372 Compare March 12, 2021 18:48
@Westbrook Westbrook marked this pull request as ready for review March 12, 2021 18:58
@Westbrook Westbrook force-pushed the westbrook/overlay-reparenting branch 6 times, most recently from 1f67e10 to 1f9e14b Compare March 19, 2021 17:35
@Westbrook Westbrook force-pushed the westbrook/overlay-reparenting branch from 1f9e14b to bfda092 Compare March 22, 2021 15:14
adixon-adobe
adixon-adobe previously approved these changes Mar 22, 2021
Copy link
Collaborator

@adixon-adobe adixon-adobe left a 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);
Copy link
Collaborator

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;
Copy link
Collaborator

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.

@Westbrook Westbrook force-pushed the westbrook/overlay-reparenting branch from bfda092 to 3445446 Compare March 22, 2021 21:47
@Westbrook Westbrook merged commit 08d1c93 into main Mar 23, 2021
@Westbrook Westbrook deleted the westbrook/overlay-reparenting branch March 23, 2021 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlay should use new reparentChildren helper

3 participants