File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,5 @@ Accepts all [`<Overlay>`](./Overlay.md) props in addition to:
5656- ` close() ` &mdash ; method to calle ` onClose ` event.
5757- ` idTitle ` &mdash ; id to set for aria title element.
5858- ` idDescription ` &mdash ; id to set for aria description element.
59+
60+ Root nodes with ` data-modal-ignore ` attribute will not be dirty mutated (to create blur effect).
Original file line number Diff line number Diff line change 11import { createElement as h } from 'react' ;
2+ import { createPortal } from 'react-dom' ;
23import { storiesOf } from '@storybook/react' ;
34import { action } from '@storybook/addon-actions' ;
45import { Modal } from '..' ;
56import { Toggle } from '../../Toggle' ;
67import ShowDocs from '../../ShowDocs'
8+ import { AfterTimeout } from '../../AfterTimeout' ;
79
810storiesOf ( 'UI/Modal' , module )
911 . add ( 'Documentation' , ( ) => h ( ShowDocs , { md : require ( '../../../docs/en/Modal.md' ) } ) )
@@ -17,9 +19,19 @@ storiesOf('UI/Modal', module)
1719 . add ( 'Button underneath' , ( ) =>
1820 < div >
1921 < button onClick = { ( ) => alert ( 'CLICKED' ) } > Click me!</ button >
20- < Modal >
21- foobar
22- </ Modal >
22+ { createPortal (
23+ < button onClick = { ( ) => alert ( 'CLICKED' ) } > This should be blurred</ button > ,
24+ document . body
25+ ) }
26+ { createPortal (
27+ < button data-modal-ignore = "" onClick = { ( ) => alert ( 'CLICKED' ) } > This element should not be blurred</ button > ,
28+ document . body
29+ ) }
30+ < AfterTimeout >
31+ < Modal >
32+ foobar
33+ </ Modal >
34+ </ AfterTimeout >
2335 </ div >
2436 )
2537 . add ( 'With inputs' , ( ) =>
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import {Overlay, IOverlayProps} from '../Overlay';
77let id = 0 ;
88const ESC = 27 ;
99
10+ const ignoreAttribute = 'data-modal-ignore' ;
11+
1012export interface IModalProps extends IOverlayProps {
1113 blur ?: number ;
1214 dontLockFocus ?: boolean ;
@@ -57,6 +59,10 @@ export class Modal extends Component<IModalProps, IModalState> {
5759 const sibling = siblings [ i ] as HTMLElement ;
5860 const sib = sibling as any ;
5961
62+ if ( sibling . hasAttribute ( ignoreAttribute ) ) {
63+ continue ;
64+ }
65+
6066 if ( sibling === this . el ) {
6167 continue ;
6268 }
@@ -101,6 +107,10 @@ export class Modal extends Component<IModalProps, IModalState> {
101107 for ( let i = 0 ; i < siblings . length ; i ++ ) {
102108 const sibling = siblings [ i ] as HTMLElement ;
103109
110+ if ( sibling . hasAttribute ( ignoreAttribute ) ) {
111+ continue ;
112+ }
113+
104114 if ( sibling === el ) {
105115 continue ;
106116 }
You can’t perform that action at this time.
0 commit comments