-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix closeOnClickOutside
for the Popover component
#423
Conversation
Generated link: snehilvj/dash-mantine-components-423 |
Hi @magicmq I'll take a closer look in a bit, but in the meantime, here is the sample app hosted on PyCafe. Note that the app is using the build from this point in the PR. It's editable so you can try different scenarios too. |
Again, nice job on the PR. Cool that it can be fixed in one line :-) Just a couple tips:
in your PR description, the associated issue will automatically close when the PR is merged, and it will indicate there's an active PR linked to that issue. Additions
Tests Have you tried following the instructions in the Contributor Guide on getting test to run locally? It can be a little tricky, but it's pretty cool once you get the hang of it. To update the current Popover test, we can extend it to check that the Popover closes when clicking outside. We can include an extra element in the test and using Selenium, locate this element, click on it, and then confirm that the Popover is closed. Here is the minimal app on PyCafe Here it is turned into a test:
|
Hi @AnnMarieW, My apologies for not creating a new branch in my fork prior to submitting the PR (still learning!). Since this was a relatively simple fix, I can start over and commit to a branch this time and recreate the PR, along with commits for the other additions you requested above. Would you like me to do that? I will look into testing locally (as well as modifying the test for the Popover component) now. I didn't get that far yesterday. |
Hey @magicmq it's not critical to create a new branch. It's ok to carry on from here as is. It's nice to keep all the comments with the PR. |
I added testing for closure on click outside to the Popover test, and it passes! All other tests pass as well with the exception of the carousel test, which I am assuming is unrelated to this change. I also committed the other changes you requested. Let me know if there's anything else that's needed! |
This looks great! 💃 |
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 great, very nice additions to the test!
Congrats on you first DMC PR @magicmq 🥳 |
Thank you both! |
Summary
Beginning with Mantine version 7.13.4, the behavior of the
onClose
prop for the Popover component was changed in relation to other bug fixes within the project. Previously, theonClose
prop was called when a user action triggered the dropdown (which meantonClose
could be used to control the state of the popover). However,onClose
is now called when the Popover actually closes, not when a trigger occurs. Therefore,onClose
is no longer a viable method for controlling the Popover's state.The Mantine developers recommend using the
onChange
prop instead to control the Popover's state (mantinedev/mantine#7019). As such, this PR updates the Popover component to utilize theonChange
method for closing the Popover rather thanonClose
.This PR should also fix
closeOnEscape
, as this too previously relied upon theonClose
prop to function correctly.Closes #420.
Changes
onChange
prop to control its state.Example
The fix is tested working with the above example, but I have not run other testing with
pytest
so I am not sure if the change is 100% passing. Let me know if you have any feedback or if you would like me to run additional testing.