Skip to content
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

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

Closed
ganlvtech opened this issue Apr 18, 2018 · 6 comments
Closed

Comments

@ganlvtech
Copy link

ganlvtech commented Apr 18, 2018

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.'
  }
});
@emanuelmutschlechner
Copy link
Contributor

As documented here onFocusout brings the focus back when tabbing.

I think this is only a minor issue because no one will hold down the left mouse when clicking on the backdrop

@ganlvtech
Copy link
Author

Enforce focus is a feature that only Bootstrap Vue has. So set no-enforce-focus to true will get behavior like pure Bootstrap.

Is that interpretation right?

@emanuelmutschlechner
Copy link
Contributor

@ganlvtech No, setting no-enforce-focus to true is not pure Bootstrap. This is a minor bug in BootstrapVue.

Click "Launch demo modal" and press TAB. You will see how the focus cycles through elements in the modal, which is exactly what enforce focus is doing
https://getbootstrap.com/docs/4.0/components/modal/#live-demo

@ganlvtech
Copy link
Author

Thanks, I got it. It's only a minor bug.

@evgenyvas
Copy link
Contributor

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

@ganlvtech
Copy link
Author

content.focus({preventScroll: true})

Nice solution! It helps a lot for me.

shinrox added a commit to shinrox/bootstrap-vue that referenced this issue Oct 26, 2018
* dev: (31 commits)
  feat(card): support left and right image placement (bootstrap-vue#1981)
  fix(collapse/toggle): "collapsed" class cleared when component updated (bootstrap-vue#2102)
  fix(form-file): Add validation of single file (bootstrap-vue#2028)
  chore(docs): minor update to the b-form-input docs
  chore(docs): Minor update to b-form-input docs
  feat(table): Add row-unhovered event (bootstrap-vue#1874)
  feat(table): Support contextmenu event binding for table rows (bootstrap-vue#2064)
  docs(table): fix minor typo (bootstrap-vue#2093)
  feat(table): Support sorting on nested object properties (bootstrap-vue#1868)
  perf(modal): optimize model.resetScrollbar, resolves bootstrap-vue#1831  (bootstrap-vue#1837)
  docs: Update images reference section (bootstrap-vue#1999)
  fix(observe-dom): fix comment typo (bootstrap-vue#2084)
  chore(modal): trivial word fix in comment (bootstrap-vue#2089)
  (docs): Fix grammer in Intro readme (bootstrap-vue#2092)
  fix(modal): prevent scrolling on .modal-content focus, fixes bootstrap-vue#1748 (bootstrap-vue#2060)
  feat(pagination):  added slots for first, prev, next, last, and ellipsis. Fixes bootstrap-vue#1870. (bootstrap-vue#1980)
  Handle state change on validated fields. (bootstrap-vue#1984)
  fix(docs): input group prepend slot typo (bootstrap-vue#2059)
  fix(dependencies): replace opencollective with opencollective-postintall (bootstrap-vue#2067)
  fix(docs): change b-input-group attribute 'left' to 'prepend' (bootstrap-vue#2017)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants