Skip to content

Dev 660 fix tooltips behavior on mobiletablet screen sizes#223

Merged
martonszak merged 4 commits intomainfrom
dev-660-fix-tooltips-behavior-on-mobiletablet-screen-sizes
Apr 21, 2026
Merged

Dev 660 fix tooltips behavior on mobiletablet screen sizes#223
martonszak merged 4 commits intomainfrom
dev-660-fix-tooltips-behavior-on-mobiletablet-screen-sizes

Conversation

@martonszak
Copy link
Copy Markdown
Contributor

@martonszak martonszak commented Apr 16, 2026

Overview

Required checks

Mark all tasks that were completed with a checkmark. Unrelated tasks can be left unchecked.

Required checks before asking for human review:

  • Branch is based on and up-to-date with main
  • PR has a clear title and brief description or reference to the relevant issue with details
  • All PR builders passed (linter, unit tests, e2e tests, visual regression tests)
  • Manual testing of new features or bugfixes along with affected pages or components
  • Redundant AI comments, unwanted complexity, and unintentional drifts cleaned up

Further required checks after all other major items in this list are completed:

  • No red flags from coderabbit.ai
  • Human approval

Summary by CodeRabbit

  • Bug Fixes
    • Tooltips now automatically dismiss when scrolling the page or within scrollable containers.
    • Improved tooltip positioning and lifecycle management for more consistent and reliable behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

The pull request implements scroll-based tooltip dismissal functionality by refactoring the UI tooltip service to register/unregister scroll listeners during the tooltip lifecycle, centralizing DOM style mutations into helper methods, and adding comprehensive unit and end-to-end tests for the new behavior.

Changes

Cohort / File(s) Summary
Tooltip Service Implementation
src/app/services/ui-tooltip.service.ts
Refactored show/hide lifecycle to centralize DOM style mutations into prepareTooltipForPositioning() and resetTooltipStyles() helpers. Added listener registration/unregistration logic to attach/remove global scroll event listeners on document and window with capture mode during tooltip display and hide operations.
Tooltip Service Tests
src/app/services/ui-tooltip.service.spec.ts
Added shared createTooltipTarget() helper for consistent test setup. Updated existing tests to use the helper. Introduced four new test cases verifying scroll-driven tooltip dismissal: window scroll, scrollable ancestor scroll, listener cleanup removal, and reset logic when replacing and hiding tooltips.
E2E Compare Tests
cypress/e2e/servers_compare.cy.ts
Introduced URL constants (COMPARE_PRICE_URL, COMPARE_36_VCPU_URL) to replace inline strings. Added showCompareTooltip() helper function to trigger tooltip via info icon interaction. Added two new test cases verifying tooltip dismissal on table scroll and page scroll events.

Sequence Diagram

sequenceDiagram
    participant User as User/<br/>Page
    participant Service as UI Tooltip<br/>Service
    participant DOM as DOM/Tooltip<br/>Element
    participant Events as Window/<br/>Document

    User->>Service: show(tooltip, anchor)
    activate Service
    Note over Service: Unregister existing<br/>listeners (if any)
    Service->>DOM: prepareTooltipForPositioning()
    Service->>DOM: Update styles
    Service->>Service: Set activeTooltipElement<br/>activeAnchorElement
    Service->>Events: registerDismissListeners()
    Service->>Events: Attach scroll listeners<br/>(capture: true)
    deactivate Service
    DOM->>DOM: display: block<br/>opacity: 1

    User->>Events: Scroll window/element
    Events->>Service: scroll event (capture)
    activate Service
    Service->>Service: hideActiveTooltip()
    Service->>Service: hide(activeTooltipElement)
    Service->>DOM: resetTooltipStyles()
    Service->>DOM: Update styles
    Service->>Events: unregisterDismissListeners()
    Service->>Events: Remove scroll listeners
    deactivate Service
    DOM->>DOM: display: none<br/>opacity: 0
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Dev 416 #152: This PR directly modifies the compare tooltip implementation (renaming/repositioning the tooltip element and structure), creating a direct code-level dependency with scroll-based dismissal additions in this PR.

Suggested reviewers

  • daroczig
  • Palabola

Poem

🐰 A scroll, a show, a tooltip's grace,
With listeners bound in the right place,
When wheels do turn or fingers swipe,
The tooltip fades—no need to gripe! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning PR description is merely a copy of the template with all checklist items checked but lacks any meaningful content about what the PR actually does or why. Add a brief overview explaining the tooltip behavior fix for mobile/tablet, reference the issue (Dev 660), and describe the changes made (scroll-based dismissal, refactoring). The title alone is insufficient.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing tooltip behavior specifically on mobile/tablet screen sizes, which aligns with all modified files focusing on tooltip dismissal via scroll events.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-660-fix-tooltips-behavior-on-mobiletablet-screen-sizes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@daroczig daroczig temporarily deployed to dev-660-fix-tooltips-behavior-on-mobiletablet-screen-sizes - sc-www PR #223 April 17, 2026 11:04 — with Render Destroyed
@martonszak martonszak marked this pull request as ready for review April 17, 2026 11:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/app/services/ui-tooltip.service.ts (1)

14-16: Consider passive: true for the scroll listener.

Since this PR targets mobile/tablet, adding passive: true lets the browser scroll without waiting on the listener and avoids any chance of triggering the Chrome "non-passive scroll listener" warning. The handler only calls hide() (no preventDefault), so making it passive is safe.

♻️ Proposed refactor
-  private readonly dismissListenerOptions: AddEventListenerOptions = {
-    capture: true,
-  };
+  private readonly dismissListenerOptions: AddEventListenerOptions = {
+    capture: true,
+    passive: true,
+  };

Also applies to: 217-241

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/services/ui-tooltip.service.ts` around lines 14 - 16, The
dismissListenerOptions object used for scroll/dismiss event listeners (private
readonly dismissListenerOptions: AddEventListenerOptions) should include
passive: true since the scroll handler only calls hide() and does not call
preventDefault; update that options object to add passive: true so the browser
can optimize scrolling and avoid non-passive listener warnings, and apply the
same change to the other scroll/dismiss listener options used later in the file
(the listener options referenced around the scroll/hide handlers and where
hide() is attached) so all scroll listeners are passive.
cypress/e2e/servers_compare.cy.ts (1)

10-24: Consider using Cypress's trigger() method for cleaner event simulation.

The component correctly binds (mouseenter) directly on the lucide-icon[name="info"] elements throughout the template, so the synthetic dispatch will work. However, cy.get('#main-table tr.rows-to-hide-for-test lucide-icon[name="info"]').first().trigger('mouseenter') is the idiomatic Cypress approach and handles event simulation more robustly than manual dispatchEvent().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cypress/e2e/servers_compare.cy.ts` around lines 10 - 24, The custom
MouseEvent dispatch in showCompareTooltip() should be replaced with Cypress's
built-in trigger for cleaner, more robust event simulation; locate
showCompareTooltip and change the body that queries '#main-table
tr.rows-to-hide-for-test lucide-icon[name="info"]' and first() so it calls
.trigger('mouseenter') (optionally with { force: true } if needed) instead of
manually creating and dispatching a new win.MouseEvent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cypress/e2e/servers_compare.cy.ts`:
- Around line 10-24: The custom MouseEvent dispatch in showCompareTooltip()
should be replaced with Cypress's built-in trigger for cleaner, more robust
event simulation; locate showCompareTooltip and change the body that queries
'#main-table tr.rows-to-hide-for-test lucide-icon[name="info"]' and first() so
it calls .trigger('mouseenter') (optionally with { force: true } if needed)
instead of manually creating and dispatching a new win.MouseEvent.

In `@src/app/services/ui-tooltip.service.ts`:
- Around line 14-16: The dismissListenerOptions object used for scroll/dismiss
event listeners (private readonly dismissListenerOptions:
AddEventListenerOptions) should include passive: true since the scroll handler
only calls hide() and does not call preventDefault; update that options object
to add passive: true so the browser can optimize scrolling and avoid non-passive
listener warnings, and apply the same change to the other scroll/dismiss
listener options used later in the file (the listener options referenced around
the scroll/hide handlers and where hide() is attached) so all scroll listeners
are passive.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 208f51c5-591d-4387-a7db-793e4cfdc326

📥 Commits

Reviewing files that changed from the base of the PR and between 50ea90a and 7c734fb.

📒 Files selected for processing (3)
  • cypress/e2e/servers_compare.cy.ts
  • src/app/services/ui-tooltip.service.spec.ts
  • src/app/services/ui-tooltip.service.ts

@martonszak martonszak requested a review from daroczig April 17, 2026 11:35
@daroczig
Copy link
Copy Markdown
Member

what about this suggestion?

image

@martonszak
Copy link
Copy Markdown
Contributor Author

what about this suggestion?

image

I'm mostly don't bother myself with nitpick comments because those are rarely critical change suggestions. The current code is fine as-is, and that passive: true is not required for correctness or meaningful performance improvement here. 🦆

Copy link
Copy Markdown
Member

@daroczig daroczig left a comment

Choose a reason for hiding this comment

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

sounds good, I trust your related decision 👍 approved :shipit:

on the other hand, we might need to still look into these at some point (independent of this update) to reduce the related warnings in the dev console:

image

might improve our lighthouse score :)

@martonszak
Copy link
Copy Markdown
Contributor Author

martonszak commented Apr 21, 2026

sounds good, I trust your related decision 👍 approved :shipit:

on the other hand, we might need to still look into these at some point (independent of this update) to reduce the related warnings in the dev console:

might improve our lighthouse score :)

I'll create a ticket in the backlog to collect all warnings and solve them when we'll have time for it! 🦺

@martonszak martonszak merged commit b2efd12 into main Apr 21, 2026
4 checks passed
@martonszak martonszak deleted the dev-660-fix-tooltips-behavior-on-mobiletablet-screen-sizes branch April 21, 2026 10:53
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.

2 participants