MudOverlay: Add parameter Modal allowing click-through#10893
Conversation
…utside of any mud-menu-list it will invoke the CloseMenuAsync method
…usedown event listening methods
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #10893 +/- ##
==========================================
+ Coverage 90.99% 91.01% +0.01%
==========================================
Files 431 436 +5
Lines 14055 14095 +40
Branches 2722 2724 +2
==========================================
+ Hits 12790 12829 +39
- Misses 650 651 +1
Partials 615 615 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I thought we were talking about putting it on the Overlay so it would apply to all controls that use the overlay instead of just mudmenu |
Ah, my misunderstanding! I’ll look into shifting it to the Overlay. |
|
I'm struggling to implement this in In the current PR, the logic checks whether the clicked event is inside any At this point, the only approach I see is for the component using I'm open to any other suggestions or insights on how best to approach this. Let me know what you think! Update |
|
so there are only a handful of popover / overlay combo controls (autocomplete, select, picker, menu?) so it's easy to look at each one. I think the only reasonable way I could think about it would be to a) create a css class on the overlay something like b) create a separate component and add Overlay true/false default to true on the components that use it, then anyone who wanted overlay functionality with clickthrough could use the new component after setting Overlay=false on the popover component. I'm unsure of this one but it's an idea that went through my head. c) create a js item that is popover agnostic and accepts an element. In each of the popover/ overlay components add a property OverlayClickThrough that when true onafterrender will attach the element to the js function. On the overlay create a method that does that allowing the dev to pass the element to the Overlay. And before I did any of those I'd wait for @danielchalmers to chime in, he may hate/love one over the other or decide not to move forward with it. That way if you do the work at least your pretty sure it will be accepted. |
|
The core issue is that once we use The fourth solution d) would be to add a new css class Letting each component add and remove the css class to elements would solve the search panel problem that Daniel encountered. Why conditionally add/remove? That is if you have two search panels next to each other, you want interaction with the other one to close the overlay from the first if shown. So the css class on the activator element would be conditionally added when the overlay is shown and removed when closed. |
|
I apologize, I can't suggest a firm direction right now. The |
|
I'll add that MUI is an interesting example: Autocomplete is non-modal, but Select and Menu are. |
Sorry, re-adding my comment. I thought I was onto something regarding how Original comment: From what I've found through research and testing, a reliable solution should focus on the element(s) containing the popup content. Using the In this context, That said, I might have misunderstood the intended usage of |
|
Just a blind one eye pass on it from behind the keyboard not running the code. so on the click handler of the mudoverlay it would check if that class exists if it does it would pass it's elementreference and event (the clientX and clientY of mouseeventargs) to a javascript function at the end of the click handler. So it completes the overlay purpose then runs the following javascript function. focusElementUnderOverlay(element, event) { // pass through |
|
For that to potentially work we would not be able to use If you run the docs server in this PR and see the updates docs example for the Menu, you can see how the cursor reacts and interacts with the elements differently depending on if the "Modal Menu" or "Non-modal Menu" is showing. Another caveat would be if it is even possible to alter the click event or simulate a new one. I think I have tried that in the past but those events are ignored as they are considered a security risk. |
|
then the flip side is onafterrender of mudoverlay you remove the click handler if that class exists, run your js, at the click of your js execute the close handler of the mudoverlay from dotnetref. In your js if the item you click has the same or higher zindex then you do nothing. Again spitballing I'm not coding some or all of this might not work like we want. |
I tried checking the z-index of the clicked element to try and compare it with the z-index of the mud overlay, to see if it's in front of it or not, but for some reason the clicked element's z-index was always lower than the overlay's. I might not have done it properly, so might be worth a retry. |
aye let me know if you have a code set that's close I'll take a look. Might be some other markers too, if they are all popovers then traverse to see if data-ticks is greater than 0, if it is it's an active popover and should be ignored. |
I did a test and the z-index was not reliable. I found some people on SO who had tried to solve it but it escalated into someone writing code that mimics/builds the visual hierarchy of the entire page with JS, let's not use that. Analyzing the DOM hierarchy, everything in front of the mud overlay will be a child under a popovercontent-div. The parent divs could be identified by the data-ticks attribute, but also the CSS classes We could solve it by either: I'll try and prep a trymud or sample with a and b to choose between. |
|
sounds good, you can use javascript on https://try.arctechonline.tech if needed |
Here's a thrown together TryMudBlazor snippet based on some of my findings and tests. Key Findings:
JavaScript Methods:
Additional Suggestion:
|
|
@versile2 @danielchalmers Persistence pays off. I had an idea and just tested it, successfully. There is a way to use Here's a TryMud snippet resembling the previous one. |
|
There might be a layout race condition, but you can force a synchronous layout reflow by accessing a property immediately after changing the style. I didn’t need to do this during my tests, but if needed, it would look like this: overlay.style.pointerEvents = "auto";
overlay.offsetHeight; // Trigger reflow |
|
This sounds exciting I won't be back to look until late tomorrow!
…On Sat, Feb 22, 2025, 3:36 PM Mikael Nensén ***@***.***> wrote:
There might be a layout race condition, but you can force a synchronous
layout reflow <https://gist.github.com/paulirish/5d52fb081b3570c81e3a> by
accessing a property immediately after changing the style. I didn’t need to
do this during my tests, but if needed, it would look like this:
overlay.style.pointerEvents = "auto";overlay.offsetHeight; // Trigger reflow
—
Reply to this email directly, view it on GitHub
<#10893 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDQDZ7CGPD6NIZK665H5KG32RDUW7AVCNFSM6AAAAABXKIVAVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWGQYTGMRWGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: Cybrosys]*Cybrosys* left a comment (MudBlazor/MudBlazor#10893)
<#10893 (comment)>
There might be a layout race condition, but you can force a synchronous
layout reflow <https://gist.github.com/paulirish/5d52fb081b3570c81e3a> by
accessing a property immediately after changing the style. I didn’t need to
do this during my tests, but if needed, it would look like this:
overlay.style.pointerEvents = "auto";overlay.offsetHeight; // Trigger reflow
—
Reply to this email directly, view it on GitHub
<#10893 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDQDZ7CGPD6NIZK665H5KG32RDUW7AVCNFSM6AAAAABXKIVAVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZWGQYTGMRWGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
ok so looks good and what is required to make this a fairly generic thing for overlay? Such as an option on Overlay for Modal true/false or do we have to add a property on everything that uses an Overlay. Walk me through it, but I like it and apart from some testing I can't see it not working right. |
|
The term I believe that the current default behavior ( If we keep to having the current behavior the default, so this would be "opt-in". I would then suggest adding the same parameter ( or This feature also ties in to |
|
Maybe add |
|
We won't purposefully introduce a breaking change outside of major releases so we must keep current behavior or shelve this until we are closer to V9. I like Modal true/false over Anything else but I also don't like having to put it on each item that uses Overlay. Also exclude Dialogs and Drawer. Those aren't our targets for this, select, autocomplete, menu are the top 3. And some way to trigger from the Overlay itself? public method SetModelessElement(ElementReference element) or something like that? |
Description
Introduces a new opt-in behavior that allows pointer events to pass through, enabling users to interact with other elements on the page directly. The overlay will close upon interaction with other elements if
AutoCloseistrue, eliminating the need for an extra dismiss click/tap.The Modal parameter has been introduced to several components that currently use
MudOverlayto handle dismissal or toggling between open and closed states, such as menus and picker controls, this to achieve the expected behavior while not blocking interaction with elements behind the overlay.#10738
Extra: #10938
How Has This Been Tested?
Unit and visually
Type of Changes
Checklist
dev).