Skip to content

MudPopover: Fix Event Order#11389

Merged
danielchalmers merged 3 commits intoMudBlazor:devfrom
versile2:tooltipfix/11288
May 26, 2025
Merged

MudPopover: Fix Event Order#11389
danielchalmers merged 3 commits intoMudBlazor:devfrom
versile2:tooltipfix/11288

Conversation

@versile2
Copy link
Contributor

@versile2 versile2 commented May 22, 2025

Description

Resolves #11303
Resolves #11288
Made 3 significant changes

  1. Scroll Container events were not firing properly (excluding body scroll)
  2. Popovers that open inside a container with css transition animation opened at the size of call not the size it ended up. Added logic to flow up in size.
  3. Popovers not in viewable area are no longer shown. e.g. a tooltip inside a scrollable container would continue to show when that container scrolls it out of view. Now it stops when the popover is 100% not visible.

How Has This Been Tested?

Visually tested in Docs and Viewer the following: Tooltips, Overlay, Popover, Autocomplete, Select, Menu

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@versile2 versile2 requested a review from danielchalmers May 22, 2025 20:29
@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels May 22, 2025
@codecov
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.10%. Comparing base (9dc076c) to head (9e4d20f).
Report is 16 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11389   +/-   ##
=======================================
  Coverage   91.10%   91.10%           
=======================================
  Files         465      465           
  Lines       14407    14407           
  Branches     2788     2788           
=======================================
  Hits        13126    13126           
  Misses        642      642           
  Partials      639      639           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielchalmers danielchalmers requested a review from Copilot May 22, 2025 21:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes event handling and repositioning issues for MudPopover, improving scroll handling and ensuring popovers are only shown when in the viewable area. Key changes include:

  • Adding an isInViewport helper to determine element visibility within scrollable containers.
  • Refactoring scroll event listener management, including storing and removing custom handlers.
  • Adjusting popover repositioning using a setInterval tied to transition timing.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/MudBlazor/TScripts/mudPopover.js Updated popover logic to improve viewport checks, scroll event handling, and repositioning during transitions.
src/MudBlazor.UnitTests.Viewer/TestComponents/Tooltip/TooltipScrollTest.razor Added a test component to verify tooltip behavior under scroll conditions.
Comments suppressed due to low confidence (1)

src/MudBlazor/TScripts/mudPopover.js:227

  • [nitpick] The isInViewport function currently returns false as soon as a scrollable container is encountered. Consider calculating the intersection of the element's bounding rectangle with its parent's visible area to better handle partial visibility scenarios.
if (isScrollableY || isScrollableX) { return false; }

@danielchalmers
Copy link
Member

The animation is fairly clunky, especially noticeable when slowed down:

Video7.mp4

and may not finish if you extend the mud-open-dialog-center animation:

Video8.mp4

@sonarqubecloud
Copy link

@versile2
Copy link
Contributor Author

versile2 commented May 23, 2025

I changed the function to look at all parents and have video showing what 25 fpd (frames per duration/delay) and 12 fpd do. In each video the first is at the default .1s and the second is at 3s. New commit is at 12fpd.

25fpd
https://github.com/user-attachments/assets/86da96c8-c2d5-4bea-a103-3f4c7fba32bf

12fpd
https://github.com/user-attachments/assets/3010a44d-bcd9-407c-b56f-786ba0fa226e

Copy link
Member

@danielchalmers danielchalmers left a comment

Choose a reason for hiding this comment

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

Looks really smooth now

@danielchalmers danielchalmers merged commit eee07f9 into MudBlazor:dev May 26, 2025
6 checks passed
@versile2 versile2 deleted the tooltipfix/11288 branch July 16, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudAutocomplete renders dropdown menu in wrong position when focused as first child in MudDialog MudTooltip doesn't update it's position on scroll

3 participants