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:
56
56
- ` close() ` &mdash ; method to calle ` onClose ` event.
57
57
- ` idTitle ` &mdash ; id to set for aria title element.
58
58
- ` 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 1
1
import { createElement as h } from 'react' ;
2
+ import { createPortal } from 'react-dom' ;
2
3
import { storiesOf } from '@storybook/react' ;
3
4
import { action } from '@storybook/addon-actions' ;
4
5
import { Modal } from '..' ;
5
6
import { Toggle } from '../../Toggle' ;
6
7
import ShowDocs from '../../ShowDocs'
8
+ import { AfterTimeout } from '../../AfterTimeout' ;
7
9
8
10
storiesOf ( 'UI/Modal' , module )
9
11
. add ( 'Documentation' , ( ) => h ( ShowDocs , { md : require ( '../../../docs/en/Modal.md' ) } ) )
@@ -17,9 +19,19 @@ storiesOf('UI/Modal', module)
17
19
. add ( 'Button underneath' , ( ) =>
18
20
< div >
19
21
< 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 >
23
35
</ div >
24
36
)
25
37
. add ( 'With inputs' , ( ) =>
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import {Overlay, IOverlayProps} from '../Overlay';
7
7
let id = 0 ;
8
8
const ESC = 27 ;
9
9
10
+ const ignoreAttribute = 'data-modal-ignore' ;
11
+
10
12
export interface IModalProps extends IOverlayProps {
11
13
blur ?: number ;
12
14
dontLockFocus ?: boolean ;
@@ -57,6 +59,10 @@ export class Modal extends Component<IModalProps, IModalState> {
57
59
const sibling = siblings [ i ] as HTMLElement ;
58
60
const sib = sibling as any ;
59
61
62
+ if ( sibling . hasAttribute ( ignoreAttribute ) ) {
63
+ continue ;
64
+ }
65
+
60
66
if ( sibling === this . el ) {
61
67
continue ;
62
68
}
@@ -101,6 +107,10 @@ export class Modal extends Component<IModalProps, IModalState> {
101
107
for ( let i = 0 ; i < siblings . length ; i ++ ) {
102
108
const sibling = siblings [ i ] as HTMLElement ;
103
109
110
+ if ( sibling . hasAttribute ( ignoreAttribute ) ) {
111
+ continue ;
112
+ }
113
+
104
114
if ( sibling === el ) {
105
115
continue ;
106
116
}
You can’t perform that action at this time.
0 commit comments