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

Neighborhood hover not working on our maps in Firefox #3777 #3796

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

heonjwa
Copy link
Collaborator

@heonjwa heonjwa commented Feb 8, 2025

Resolves #3777

Configured tooltopTimout variable to handle flickering on toolbox when hovered by adding slight delay when removing tool tip which gives the user time to move their mouse onto the tooltip.

Before/After screenshots (if applicable)
before.mp4
after.mp4
Testing instructions
  1. Open up firefox and hover over label map and check whether there is flickering.
Things to check before submitting the PR
  • I've written a descriptive PR title.
  • I've added/updated comments for large or confusing blocks of code.
  • I've included before/after screenshots above.
  • I've asked for and included translations for any user facing text that was added or modified.
  • I've updated any logging. Clicks, keyboard presses, and other user interactions should be logged. If you're not sure how (or if you need to update the logging), ask Mikey. Then make sure the documentation on this wiki page is up to date for the logs you added/updated.
  • I've tested on mobile (only needed for validation page).

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

Seems to be working nicely! I tested on Chrome and Firefox for now. Are you using a Mac? If so, have you checked that it's working on Safari as well?

I also added a couple of comments throughout the code to address. Nothing major!

// Add listeners to popup so the popup closes when the mouse leaves the popup area.
neighborhoodTooltip._content.onmouseout = function (e) {
if (!e.toElement || !e.toElement.closest('.mapboxgl-popup')) {
// Clear timeout when entering new toolTip
Copy link
Member

Choose a reason for hiding this comment

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

Very small thing, but just take a quick look through the Style Guide. Want comments ending in a period, etc. Sorry, still need to get the linter set up to do this stuff automatically!

// Clear timeout when entering new toolTip
neighborhoodTooltip._content.onmouseenter = function () {
if (tooltipTimeout) {
clearTimeout(tooltipTimeout); // Clear the timeout if the mouse enters the tooltip
Copy link
Member

Choose a reason for hiding this comment

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

This comment also feels redundant. The outer comment summarizes what happens here well enough, and what you're doing is simple enough. I think it would be cleaner to just rewrite it like:

                // Clear timeout when entering a tooltip.
                neighborhoodTooltip._content.onmouseenter = function () {
                    if (tooltipTimeout) clearTimeout(tooltipTimeout);
                };

// Clear timeout when entering new toolTip
neighborhoodTooltip._content.onmouseenter = function () {
if (tooltipTimeout) {
clearTimeout(tooltipTimeout); // Clear the timeout if the mouse enters the tooltip
Copy link
Member

Choose a reason for hiding this comment

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

And when we call clearTimeout we're actually never unsetting the tooltipTimeout variable. So after the first tooltip opens, tooltipTimeout will never be falsey. Which is fine, because we can keep trying to clear the timeout for a timer that's already been cleared. Similarly, we can keep calling clearTimeout on undefined! So maybe let's just not bother with checking if tooltipTimeout is defined to simplify things even more:

                // Clear timeout when entering a tooltip.
                neighborhoodTooltip._content.onmouseenter = function () { clearTimeout(tooltipTimeout); };

And we can simplify in the same way throughout

@misaugstad
Copy link
Member

And make sure to pull in most recent changes to develop! You were behind by 25 commits or so, but I pulled in changes while I was testing this time!

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.

Neighborhood hover not working on our maps in Firefox
2 participants