-
Notifications
You must be signed in to change notification settings - Fork 142
Enable user to configure modal's scrollBehavior #2355
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
Enable user to configure modal's scrollBehavior #2355
Conversation
Previously, modal is rendered properly when both scroll-behavior='outside' and center='true' is set. Remove effect of centering modal when scroll-behavior is set to 'outside'. center='true' has effect only if scroll-behavior is set to 'inside'
Codecov Report
@@ Coverage Diff @@
## master #2355 +/- ##
==========================================
+ Coverage 44.82% 45.11% +0.28%
==========================================
Files 122 123 +1
Lines 5133 5165 +32
Branches 1082 1086 +4
==========================================
+ Hits 2301 2330 +29
- Misses 2513 2516 +3
Partials 319 319
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@jmestxr is this PR ready for review? |
|
@MarkBind/active-devs for your review ... |
| // To adjust modal styles according to scrollBehavior | ||
|
|
||
| const modal = $vfm.get(this.id)[0].$el; | ||
| const modalContainer = modal.querySelector('.vfm__container'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the properties mentioned here help you in the stuff you are doing below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I can use those to refactor some of the styles to the <style> sheet, together with data() props. But I still need to use javascript to set overflow-y to the outermost container, and query the overflowed content height to adjust the modal container height.
I have just committed those changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For outermost container, does using <vue-final-modal> class="abc" work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works. Thanks!
|
Wondering whether bootstrap Modal's |
Ah, this actually solves a previous PR #2322 in a more straightforward manner I'll revert the solution from #2322 and use |
|
@jmestxr
When clicking on the outside scrollbar, i'm getting the same old error of auto closing the entire modal. Could you verify/re-check? In fact I just checked the preview of UG here Encountering this exact error as well. |
Apologies! I have just done a fix, notably for the calculation of |
Okay, perhaps dynamically changing the height isn't the best way to go. Solution will become too unnecessarily complex just for this issue. Either way it doesn't solve the actual problem that the scroll-bar is within the closable area of the modal. Perhaps should instead try migrating vue-final-modal to higher versions which doesn't seem to have this issue: https://vue-final-modal.org/use-cases/modal-long-scroll I think I'll close this PR and meanwhile open a new issue for solving #2322 using |
Agreed. Good exploration still 👍 I think the solution that I would go with is to either wait till we migrate vue-final-modal, or do a deep dive into the package, and find out what changes did they make to fix this issue in newer versions (might take time and have complicated issues, so I'm not recommending).
Sure, if it turns out that using |
Will do. Thanks for the review @tlylt ! |



What is the purpose of this pull request?
Closes #2327
Fixes #2322
Overview of changes:
User can now configure scroll position of modal by setting
scroll-behaviorprop to be'inside'(default) or'outside', e.g.<modal scroll-behavior='outside'> ...The modal CSS styles for the respective
scroll-behaviorvalues are set within theopened()method which is called after modal is opened (see @opened event here).For
scroll-behavior = 'outside', basically what I did was:overflow-yproperty of the outermost modal container toscroll, which allowed user to mouseclick on scrollbar without causing modal to close unexpectedly. However, it resulted in this:where the grey area is the part that user can click to close the modal and the white area is the overflow part.
Screen.Recording.2023-08-16.at.11.37.44.PM.mov
Anything you'd like to highlight/discuss:
When both
scroll-behavior='outside'andcenter='true'are set, modal does not render properly when content overflows. To fix this, I modified the code such thatcenter='true'only takes effect whenscroll-behavior='inside'.Testing instructions:
packages/cli/test/functional/test_siteand runmarkbind serve -dtest_site/testModals.htmlin browser and test out the modalsProposed commit message: (wrap lines at 72 characters)
Checklist: ☑️