-
Notifications
You must be signed in to change notification settings - Fork 69
fix: do not delay auto-adding Popover by beforeClientResponse
#7563
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
If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected. This fix adds a detach listener to popover and tries to reattach it in case of: - the popover instance has been auto-added - the target element is present - the target element is still attached to the page Fixes #7505
public void openDialogAndSetTarget_closeDialog_popoverOpens() { | ||
// Clear the target and remove the popover first to ensure the popover | ||
// is auto-added when the dialog opens | ||
clickElementWithJs("clear-target"); | ||
clickElementWithJs("remove-popover"); | ||
|
||
clickElementWithJs("open-dialog"); | ||
clickElementWithJs("close-dialog"); | ||
|
||
clickTarget(); | ||
checkPopoverIsOpened(); | ||
} |
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 tried to avoid adding an IT and use a unit test instead, but with no luck. I tried something like:
@Test
public void targetAddedToPage_modalElementOpenedAndClosed_popoverAutoAddedToPage() {
Popover popover = new Popover();
Div target = new Div();
popover.setTarget(target);
ui.add(target);
Div modalElement = new Div();
ui.setChildComponentModal(modalElement, true);
fakeClientResponse();
Assert.assertEquals(modalElement.getElement(),
popover.getElement().getParent());
ui.remove(modalElement);
modalElement.getElement().removeAllChildren();
modalElement.getElement().removeFromTree();
// popover.getElement().removeFromTree();
fakeClientResponse();
Assert.assertEquals(ui.getElement(), popover.getElement().getParent());
}
But the detach listener in the Popover class wasn't being called.
...flow-parent/vaadin-popover-flow/src/main/java/com/vaadin/flow/component/popover/Popover.java
Outdated
Show resolved
Hide resolved
...-flow-integration-tests/src/test/java/com/vaadin/flow/component/popover/tests/PopoverIT.java
Show resolved
Hide resolved
beforeClientResponse
|
* fix: reattach auto-added Popover If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected. This fix adds a detach listener to popover and tries to reattach it in case of: - the popover instance has been auto-added - the target element is present - the target element is still attached to the page Fixes #7505 * test: add a test scenario for the use-case being fixed * refactor: auto-add popover to target parent * test: wait for dialog element to be removed --------- Co-authored-by: Sascha Ißbrücker <[email protected]>
* fix: reattach auto-added Popover If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected. This fix adds a detach listener to popover and tries to reattach it in case of: - the popover instance has been auto-added - the target element is present - the target element is still attached to the page Fixes #7505 * test: add a test scenario for the use-case being fixed * refactor: auto-add popover to target parent * test: wait for dialog element to be removed --------- Co-authored-by: Sascha Ißbrücker <[email protected]>
… (#7579) * fix: reattach auto-added Popover If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected. This fix adds a detach listener to popover and tries to reattach it in case of: - the popover instance has been auto-added - the target element is present - the target element is still attached to the page Fixes #7505 * test: add a test scenario for the use-case being fixed * refactor: auto-add popover to target parent * test: wait for dialog element to be removed --------- Co-authored-by: Diego Cardoso <[email protected]> Co-authored-by: Sascha Ißbrücker <[email protected]>
… (#7578) * fix: reattach auto-added Popover If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected. This fix adds a detach listener to popover and tries to reattach it in case of: - the popover instance has been auto-added - the target element is present - the target element is still attached to the page Fixes #7505 * test: add a test scenario for the use-case being fixed * refactor: auto-add popover to target parent * test: wait for dialog element to be removed --------- Co-authored-by: Diego Cardoso <[email protected]> Co-authored-by: Sascha Ißbrücker <[email protected]>
Description
If a popover tries to auto-add itself when another modal element is opened, it may end up being added as a child of said element. That can be problematic in case the target element is not part of the parent modal element and, when the modal is closed, the popover instance is removed with its parent and interacting with the target element won't work as expected.
This fix adds a detach listener to popover and tries to reattach it in case of:
Fixes #7505
Type of change