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

Fix sticky margin when a modal is opened #23669

Merged
merged 4 commits into from
Aug 25, 2017

Conversation

vtenfys
Copy link

@vtenfys vtenfys commented Aug 25, 2017

Fixes #23661

Previously white space was visible to the right of sticky elements due to right padding being added to the body. This fixes twbs#23661.
@vtenfys vtenfys changed the title Fix sticky margin Fix sticky margin when a modal is opened Aug 25, 2017
@XhmikosR XhmikosR requested a review from Johann-S August 25, 2017 11:31
@@ -68,6 +68,7 @@ const Modal = (($) => {
DATA_TOGGLE : '[data-toggle="modal"]',
DATA_DISMISS : '[data-dismiss="modal"]',
FIXED_CONTENT : '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
STICKY_CONTENT : '.sticky-top',
Copy link
Member

@Johann-S Johann-S Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.sticky-top is in FIXED_CONTENT so I don't see the interest to add a new constant here 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because sticky elements also need the padding which was and still is applied to all fixed elements, in addition to the new margin, to have the correct position. However, I could change the references to STICKY_CONTENT to the string .sticky-top if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's fine I just wanted to understand your thinking 👍☺️

js/src/modal.js Outdated
// Restore navbar-toggler margin
$(Selector.NAVBAR_TOGGLER).each((index, element) => {
// Restore sticky content and navbar-toggler margin
$(Selector.STICKY_CONTENT).add(Selector.NAVBAR_TOGGLER).each((index, element) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here you should do something like that :

$(`${Selector.STICKY_CONTENT} ${Selector.NAVBAR_TOGGLER}`)

instead of .add

Copy link
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Johann-S Johann-S merged commit ba6a6f1 into twbs:v4-dev Aug 25, 2017
@mdo mdo mentioned this pull request Aug 25, 2017
@vtenfys vtenfys deleted the fix-sticky-margin branch August 27, 2017 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants