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: Apply any preexisting body padding again after closing #15930

Merged
merged 1 commit into from
Feb 26, 2015

Conversation

hnrch02
Copy link
Collaborator

@hnrch02 hnrch02 commented Feb 26, 2015

Modifies #15273 to ignore padding set via CSS.

@hnrch02 hnrch02 added the js label Feb 26, 2015
@hnrch02 hnrch02 added this to the v3.3.4 milestone Feb 26, 2015
@hnrch02 hnrch02 force-pushed the modal-restore-inline-padding branch 2 times, most recently from 78ab28f to 5c9af62 Compare February 26, 2015 05:34
@@ -259,11 +260,12 @@

Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
this.originalBodyPad = this.$body.attr('style') ? bodyPad : null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this break with something like:

body { padding-right: 5px; }
<body style="color: red;">

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, that's why I haven't merged it yet. Was thinking about checking it with /padding-right/i, what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about !!this.$body[0].style.paddingRight ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Much better - I keep forgetting that Element.style does not include computed styles.

@hnrch02
Copy link
Collaborator Author

hnrch02 commented Feb 26, 2015

@cvrebert LGTY now? Added another unit test for the case you described.

@cvrebert
Copy link
Collaborator

What about <body style="padding-right: 5%">? I think the current code would replace 5% with its calculated pixel value when doing the restoration.

@hnrch02
Copy link
Collaborator Author

hnrch02 commented Feb 26, 2015

Good catch. If only I was as wise as you are :bowtie:

@cvrebert
Copy link
Collaborator

What would programming be without edge cases? :-P

@@ -259,11 +260,12 @@

Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
this.originalBodyPad = document.body.style.paddingRight || null
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about || '' instead of || null, and then getting rid of the ternary below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm getting a little tired, that I could have noticed.

@hnrch02
Copy link
Collaborator Author

hnrch02 commented Feb 26, 2015

Nothing of interest, certainly 😄

.bootstrapModal('show')
})

QUnit.test('should ignore values set via CSS when trying to restore body padding after closing', function (assert) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test description needs to be updated

@cvrebert
Copy link
Collaborator

Once that description is fixed, 👍 💯 :shipit:

hnrch02 added a commit that referenced this pull request Feb 26, 2015
Modal: Apply any preexisting body padding again after closing
@hnrch02 hnrch02 merged commit 442d2dd into master Feb 26, 2015
@hnrch02 hnrch02 deleted the modal-restore-inline-padding branch February 26, 2015 07:13
@cvrebert cvrebert mentioned this pull request Feb 26, 2015
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.

None yet

3 participants