File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
assets/stylesheets/blacklight Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 2727 white-space : nowrap ;
2828}
2929
30- .modal [open ] {
30+ // Blacklight's decision to try to use bootstrap modal CSS with an html5 dialog --
31+ // in such a way the <dialog> element actually serves as the modal backdrop --
32+ // requires some fixes to both bootstrap CSS and user-agent default css
33+ dialog .modal [open ] {
3134 // override bootstrap .modal class default display: none
3235 // since we aren't using bootstrap JS that sets and unsets the display
3336 display : block ;
3437 background : none ;
3538 border : none ;
39+
40+ max-height : unset ; // override user-agent dialog
41+ max-width : unset ; // override user-agent dialog
3642}
Original file line number Diff line number Diff line change 5656const Modal = ( ( ) => {
5757 const modal = { }
5858
59+ // bootstrap class that will stop body scrolling when modal is open
60+ const bootstrapBodyClassOpen = "modal-open" ;
61+
5962 // a Bootstrap modal div that should be already on the page hidden
6063 modal . modalSelector = '#blacklight-modal' ;
6164
@@ -170,6 +173,12 @@ const Modal = (() => {
170173 dom . dispatchEvent ( e )
171174
172175 dom . close ( )
176+
177+ // Turn body scrolling back to what it was
178+ document . body . style [ "overflow" ] = modal . originalBodyOverflow ;
179+ document . body . style [ "padding-right" ] = modal . originalBodyPaddingRight ;
180+ modal . originalBodyOverflow = undefined ;
181+ modal . originalBodyPaddingRight = undefined ;
173182 }
174183
175184 modal . show = function ( el ) {
@@ -181,6 +190,12 @@ const Modal = (() => {
181190 dom . dispatchEvent ( e )
182191
183192 dom . showModal ( )
193+
194+ // Turn off body scrolling
195+ modal . originalBodyOverflow = document . body . style [ 'overflow' ] ;
196+ modal . originalBodyPaddingRight = document . body . style [ 'padding-right' ] ;
197+ document . body . style [ "overflow" ] = "hidden"
198+ document . body . style [ "padding-right" ] = "0px"
184199 }
185200
186201 modal . target = function ( ) {
You can’t perform that action at this time.
0 commit comments