modal with long content on click backdrop will scroll to .modal-content top
See original GitHub issueSystem Information
- Windows 10
- Google Chrome (64bit) 64.0.3282.186
Description
Test code can be found on CodePen. I have also run the test code on Edge and IE 11. There is nothing wrong on Edge. But on IE 11, it has the same problem.
When I click the backdrop and hold left mouse button down, the content will scroll to .modal-content
's top. As a result, the scrollTop
attribute of .modal
will change to 28px
(or 1.75rem
) from zero.
I found it may be caused by the onFocusout
listener of .modal-content
. I can set no-enforce-force
to true
to prevent this problem, but I don’t know the reason why browsers behave differently.
Test script
<div id="app">
<b-btn @click="show = true">Show modal</b-btn>
<b-modal v-model="show">
<p class="my-4">{{ content }}</p>
</b-modal>
</div>
var app = new Vue({
el: '#app',
data: {
show: false,
content: 'A modal with ' + 'very '.repeat(500) + 'long content.'
}
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Bootstrap modal: background jumps to top on toggle
When the modal opens a modal-open class is set to the <body> tag. This class sets overflow: ... This will help you to...
Read more >Modal - Bootstrap
Modals are built with HTML, CSS, and JavaScript. · Clicking on the modal “backdrop” will automatically close the modal. · Bootstrap only supports...
Read more >Bootstrap Modal - examples & tutorial
Modal is a responsive popup used to display extra content. ... content scrolls instead. Clicking on the modal “backdrop” will automatically close the...
Read more >Modal · Boosted v5.1
Live demo; Static backdrop; Scrolling long content; Vertically centered; Tooltips and popovers; Using the grid; Varying modal content; Toggle between modals ...
Read more >Considerations for Styling a Modal | CSS-Tricks
There is that whole thing with main document scrollbar that Bootstrap does when it sets overflow: hidden on body so content outside modal...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In
onFocusout
function instead ofcontent.focus()
must be:content.focus({preventScroll: true})
It fix this bug for me.Nice solution! It helps a lot for me.