Skip to content

Commit ef3d810

Browse files
authored
fix(modal): bodyfixed selector did not work with existing padding
When a modal opens and the screen ist large, so there exists a scrollbar, selected fixed elements on the screen are adjusted so they dont move while the screen is shown/closed. The fixed nag element was missing to be supported existing values for padding were not taken into account. For all previous selectors (toast-container, menu, sidebar) this was not a problem, because they haven't had a padding by default. But the new nag selector actually has a padding of 1em. In case a non fixed selector was used, the padding was the wrong approach (for example the close icon inside the nag) When the modal hides, the previously set values for padding were overridden by 0. Whenever there was a default padding before, this would not work anymore. I now completely removed the inline style instead.
1 parent ec80f1e commit ef3d810

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/definitions/modules/modal.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,12 @@ $.fn.modal = function(parameters) {
680680
bodyMargin: function() {
681681
var position = module.can.leftBodyScrollbar() ? 'left':'right';
682682
$body.css('margin-'+position, initialBodyMargin);
683-
$body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, initialBodyMargin);
683+
$body.find(selector.bodyFixed.replace('right',position)).each(function(){
684+
var el = $(this),
685+
attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
686+
;
687+
el.css(attribute, '');
688+
});
684689
}
685690
},
686691

@@ -898,7 +903,12 @@ $.fn.modal = function(parameters) {
898903
if(settings.detachable || module.can.fit()) {
899904
$body.css('margin-'+position, tempBodyMargin + 'px');
900905
}
901-
$body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, tempBodyMargin + 'px');
906+
$body.find(selector.bodyFixed.replace('right',position)).each(function(){
907+
var el = $(this),
908+
attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
909+
;
910+
el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
911+
});
902912
},
903913
clickaway: function() {
904914
if (!settings.detachable) {
@@ -1294,7 +1304,7 @@ $.fn.modal.settings = {
12941304
deny : '.actions .negative, .actions .deny, .actions .cancel',
12951305
modal : '.ui.modal',
12961306
dimmer : '> .ui.dimmer',
1297-
bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar'
1307+
bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close'
12981308
},
12991309
error : {
13001310
dimmer : 'UI Dimmer, a required component is not included in this page',

0 commit comments

Comments
 (0)