Skip to content

Commit f12057d

Browse files
committed
fix(Modal): add workaround for Modal auto focus
Check if the dialog has a parent which can receive focus before trying to focus it. This workaround will allow react 16 to use Modal without forcing autoFocus={false}
1 parent bb00f4c commit f12057d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Modal.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ class Modal extends React.Component {
228228

229229
// check if modal should receive focus
230230
if (this._focus) {
231-
this._dialog.parentNode.focus();
231+
if (this._dialog && this._dialog.parentNode && typeof this._dialog.parentNode.focus === 'function') {
232+
this._dialog.parentNode.focus();
233+
}
232234
this._focus = false;
233235
}
234236
}

0 commit comments

Comments
 (0)