Skip to content
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

Close calendar event popover when clicking outside it #337

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

melissawm
Copy link
Member

@melissawm melissawm commented Jan 28, 2024

References and relevant issues

Closes napari/napari-sphinx-theme#138, together with napari/napari-sphinx-theme#147

Description

Clicking outside of the calendar event modal or pressing the ESC key closes the modal.

Also closes event popover on ESC key press.
@melissawm melissawm changed the title Close event popover when clicking outside it Close calendar event popover when clicking outside it Jan 28, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 28, 2024
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
modal.onclick = function(event) {
if (event.target.id == "myModal") {
Copy link
Member

@psobolewskiPhD psobolewskiPhD Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a stupid question (definitely a naive one): Should there be a ! or a not somewhere here to trigger when the click is outside the modal target area?
(I've not tested this because on CI the calendar events don't show)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah my intuition is the same as you @psobolewskiPhD, very good catch!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no, MyModal is the shadow that is overlayed in front of the whole page while the popover itself is the event, so this is correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, amazing! Maybe change the name to "mySneakyBackgroundHidingModalNotTheModalYouReThinking"??? 😜

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melissawm so to clarify, this will only work once the new theme is released and the constraints are upgraded, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is correct. But I prefer to change the name of myModal to something more readable. For example, eventDetailBackground

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Czaki that would require a theme change, right? I suggest we merge this and then make the parallel changes after releasing 0.4.19...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It works with current theme:
obraz

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused: isn't the ID of the background set by the theme? Clearly this is not an arbitrary string, this is a string matching an element of the DOM? Where is the ID of the modal coming from if not the theme?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the expression if (event.target.id == "myModal")

@jni jni added this to the 0.4.19 milestone Jan 31, 2024
@Czaki Czaki merged commit dac7042 into napari:main Jan 31, 2024
6 checks passed
jni pushed a commit that referenced this pull request Jan 31, 2024
# References and relevant issues

#337 (comment)

# Description

Rename to increase code readability
Czaki added a commit to napari/napari that referenced this pull request Jan 31, 2024
# References and relevant issues

napari/docs#337 (comment)

# Description

Rename to increase code readability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar details view improvement suggestions
4 participants