-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Decouple Modal's scrollbar functionality #33245
Conversation
Please can somebody explain me the usage and the checks of this code block? if ((!isBodyOverflowing && isModalOverflowing && !isRTL()) || (isBodyOverflowing && !isModalOverflowing && isRTL())) {
this._element.style.paddingLeft = `${scrollbarWidth}px`
}
if ((isBodyOverflowing && !isModalOverflowing && !isRTL()) || (!isBodyOverflowing && isModalOverflowing && isRTL())) {
this._element.style.paddingRight = `${scrollbarWidth}px`
} |
eef7dd0
to
eac1d74
Compare
d1d9489
to
02404f7
Compare
6d51216
to
21dd1e4
Compare
21dd1e4
to
582d484
Compare
582d484
to
1104ebc
Compare
54f11b1
to
fc47b68
Compare
Found it: #14933 But that's not everything.. I decided to go down the rabbit hole. So let's begin:
The Thoughts: So I checked the examples in our documentation and this doesn't seem to work properly. (This is true for older Bootstrap versions too. Maybe it did at some point tho.) The result, the dialog isn't centered properly. (At least in FF and Chrome on Windows. Safari 14 and Chrome on Android is fine tho.) About In general without those extra paddings it seems to work fine for me. |
@alpadev what a lovely approach 🛩️ 129 line this._adjustDialog() is pointless for sure, cause it hidden as you told I am not sure for the other two usages (resize 304 / handleUpdate 211) And one more cherry, that is out of this scope: lines 405|407 & 414|419 seems redundant as element |
So I made a codepen for the case when the body doesn't overflow. Since I tried it on the documentation page. There is padding-right added because the body does overflow (Case There is no case for when both are overflowing or both are not overflowing. Also the |
My guess this was added so in case when you click on a static backdrop and it would do this little animation, it's not causing any scrollbars on the backdrop if it reaches outside but not sure. |
Likely related: #31845 |
ee866fe
to
8538f88
Compare
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.
Everything else LGTM 👍
@@ -8,7 +8,7 @@ | |||
import SelectorEngine from '../dom/selector-engine' | |||
import Manipulator from '../dom/manipulator' | |||
|
|||
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed' | |||
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top' |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
I wish would be me :P
In this PR I just remove the copied the code, out of modal.
It was written like this. I am trying to finish this and a new issue waits #33580 (afraid of how many tests need to tweak)
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
That animation is transform scale, and transforming any element does not affect the layout of the real DOM element 🤔 |
@@ -49,7 +49,7 @@ const reset = () => { | |||
const _resetElementAttributes = (selector, styleProp) => { | |||
SelectorEngine.find(selector).forEach(element => { | |||
const value = Manipulator.getDataAttribute(element, styleProp) | |||
if (typeof value === 'undefined' && element === document.body) { | |||
if (typeof value === 'undefined') { |
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.
I was just thinking if the value was not stored on the data attribute then why the style prop it is being removed from the element? 🤔
Since if the value
here:
const value = Manipulator.getDataAttribute(element, styleProp)
is undefined
, it means that the style prop was not added by the bootstrap and that's why should not be removed (that style prop might be present on the dom element already added by the end-user)
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.
you are right on this.
I will keep it as default, and we can discuss it on a next PR
0302957
to
c197559
Compare
@rohit2sharma95 Check for yourself 🙂 https://jsfiddle.net/z1pb7c9w/ |
c197559
to
28e0101
Compare
@GeoSot BrowserStack tests broke. Please temporarily push any PRs that are not made from an upstream branch so that you check if everything is fine before we merge :) EDIT: NVM, it seems it was just a fluke. That being said, let's make sure BrowserStack tests pass for PRs coming from your fork. |
Scorllbar. js
is the exact same code ofmodal.js
which handles all the scrollbar functionality.It is extracted, self-tested and used on Offcanvas with success, and it can be used on modal.js through methods
preview