feat(modal): add position prop, default to middle#1091
Open
David-Crty wants to merge 1 commit into
Open
Conversation
Adds a `position` prop that maps to daisyUI's modal position modifiers (`modal-top`, `modal-middle`, `modal-bottom`, `modal-start`, `modal-end`). Defaults to `middle` to fix a long-standing mobile UX papercut: daisyUI's bare `.modal-box` (i.e. no position class) uses `max-height: 100vh` with no margin, so when content exceeds the viewport the close button and the modal-action row get clipped under the browser chrome on mobile. Setting a position modifier applies the documented `calc(100vh - 5em)` buffer. Opt out with `position=""` to keep the previous edge-to-edge behavior.
2 tasks
Owner
|
There is no need of a extra attribute. All classes are merged together at This <x-modal ... class="modal-top" />Becomes <div class="modal modal-top" /> |
Author
|
Yes, I agree; to me, it's just a way to have a "better default." Current default modals are broken on mobile when they exceed the height of the screen. |
Owner
|
I think this a daisyUI stuff on recent updates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
positionprop to<x-modal>mapping to daisyUI's position modifiers:top,middle,bottom,start,end. Default ismiddle.Why
Mary currently renders
<dialog class="modal">with no position class. daisyUI's bare.modal-boxusesmax-height: 100vhwith no margin — only themodal-middle/top/bottomvariants get thecalc(100vh - 5em)buffer.On mobile,
100vhextends under the browser chrome, so when content overflows, the close button (absolute top-2) andmodal-actionrow are clipped:Before - close button hidden at top:

After
