'
diff --git a/js/tests/unit/util/scrollbar.spec.js b/js/tests/unit/util/scrollbar.spec.js
index 280adb8e5a60..0f8f23024a38 100644
--- a/js/tests/unit/util/scrollbar.spec.js
+++ b/js/tests/unit/util/scrollbar.spec.js
@@ -48,61 +48,64 @@ describe('ScrollBar', () => {
clearBodyAndDocument()
})
- describe('isBodyOverflowing', () => {
- it('should return true if body is overflowing', () => {
- document.documentElement.style.overflowY = 'scroll'
- document.body.style.overflowY = 'scroll'
- fixtureEl.innerHTML = [
- ''
- ].join('')
- const result = new ScrollBarHelper().isOverflowing()
-
- if (isScrollBarHidden()) {
- expect(result).toEqual(false)
- } else {
- expect(result).toEqual(true)
- }
- })
+ describe('getWidth', () => {
+ describe('Body', () => {
+ it('should return an integer greater than zero, if body is overflowing', () => {
+ doc.style.overflowY = 'scroll'
+ document.body.style.overflowY = 'scroll'
+ fixtureEl.innerHTML = [
+ ''
+ ].join('')
+ const result = new ScrollBarHelper().getWidth()
- it('should return false if body is not overflowing', () => {
- doc.style.overflowY = 'hidden'
- document.body.style.overflowY = 'hidden'
- fixtureEl.innerHTML = [
- ''
- ].join('')
- const scrollBar = new ScrollBarHelper()
- const result = scrollBar.isOverflowing()
+ if (isScrollBarHidden()) {
+ expect(result).toBe(0)
+ } else {
+ expect(result).toBeGreaterThan(1)
+ }
+ })
- expect(result).toEqual(false)
- })
- })
+ it('should return 0 if body is not overflowing', () => {
+ document.documentElement.style.overflowY = 'hidden'
+ document.body.style.overflowY = 'hidden'
+ fixtureEl.innerHTML = [
+ ''
+ ].join('')
- describe('getWidth', () => {
- it('should return an integer greater than zero, if body is overflowing', () => {
- doc.style.overflowY = 'scroll'
- document.body.style.overflowY = 'scroll'
- fixtureEl.innerHTML = [
- ''
- ].join('')
- const result = new ScrollBarHelper().getWidth()
+ const result = new ScrollBarHelper().getWidth()
- if (isScrollBarHidden()) {
- expect(result).toBe(0)
- } else {
- expect(result).toBeGreaterThan(1)
- }
+ expect(result).toEqual(0)
+ })
})
- it('should return 0 if body is not overflowing', () => {
- document.documentElement.style.overflowY = 'hidden'
- document.body.style.overflowY = 'hidden'
- fixtureEl.innerHTML = [
- ''
- ].join('')
+ describe('Element', () => {
+ it('should return an integer greater than zero, if wrapper element is overflowing', () => {
+ fixtureEl.innerHTML = [
+ '
' +
+ ' ' +
+ '
'
+ ].join('')
+ const wrapper = fixtureEl.querySelector('.wrapper')
+ const result = new ScrollBarHelper(wrapper).getWidth()
+
+ if (isScrollBarHidden()) {
+ expect(result).toBe(0)
+ } else {
+ expect(result).toBeGreaterThan(1)
+ }
+ })
- const result = new ScrollBarHelper().getWidth()
+ it('should return 0 if wrapper element is not overflowing', () => {
+ fixtureEl.innerHTML = [
+ '
' +
+ ' ' +
+ '
'
+ ].join('')
+ const wrapper = fixtureEl.querySelector('.wrapper')
+ const result = new ScrollBarHelper(wrapper).getWidth()
- expect(result).toEqual(0)
+ expect(result).toEqual(0)
+ })
})
})
diff --git a/scss/_modal.scss b/scss/_modal.scss
index 21e1258f55f6..ac42f72cfaa1 100644
--- a/scss/_modal.scss
+++ b/scss/_modal.scss
@@ -88,6 +88,16 @@
@include overlay-backdrop($zindex-modal-backdrop, $modal-backdrop-bg, $modal-backdrop-opacity);
}
+// custom root specified
+.modal-open:not(body) {
+ .modal,
+ .modal-backdrop {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ }
+}
+
// Modal header
// Top section of the modal w/ title and dismiss
.modal-header {
diff --git a/site/content/docs/5.0/components/modal.md b/site/content/docs/5.0/components/modal.md
index e6a838aac284..084e4c2beb2a 100644
--- a/site/content/docs/5.0/components/modal.md
+++ b/site/content/docs/5.0/components/modal.md
@@ -564,6 +564,44 @@ Be sure to add `aria-labelledby="..."`, referencing the modal title, to `.modal`
Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. [See this helpful Stack Overflow post](https://stackoverflow.com/questions/18622508/bootstrap-3-and-youtube-in-modal) for more information.
+### Configuring root element
+
+Specify `data-bs-root-element` attribute
+```html
+
+
+```
+
+Or pass it in the config via JavaScript
+
+```js
+var modal = bootstrap.Modal(document.getElementById('modal'), {
+ rootElement: document.getElementById('another-element')
+});
+```
+{{< example >}}
+
+
+
+
+
+
+
+
+
Modal in a container
+
+
+
+ ...
+
+
+
+
+
+
+{{< /example >}}
## Optional sizes
Modals have three optional sizes, available via modifier classes to be placed on a `.modal-dialog`. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.
@@ -877,6 +915,12 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
true
Puts the focus on the modal when initialized.
+
+
rootElement
+
string or element
+
document.body
+
Configure the container that the modal resides in.