question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modal with long content on click backdrop will scroll to .modal-content top

See original GitHub issue

System 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
evgenyvascommented, Oct 3, 2018

In onFocusout function instead of content.focus() must be: content.focus({preventScroll: true}) It fix this bug for me.

0reactions
ganlvtechcommented, Oct 4, 2018

content.focus({preventScroll: true})

Nice solution! It helps a lot for me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found