blur focused element in a screen when it is under a modal

This commit is contained in:
NikolaBorislavovHristov 2019-01-22 12:07:04 +02:00
parent 196267f7f8
commit d2dd49a832

View file

@ -28,6 +28,15 @@ class FocusableProvider extends Component {
nextState.focusable !== this.state.focusable;
}
componentDidUpdate(prevProps, prevState) {
if (!this.state.focusable) {
const focusedElement = this.childElementRef.current.querySelector(':focus');
if (focusedElement) {
focusedElement.blur();
}
}
}
containerClildListOnChange = () => {
this.setState({ focusable: this.childElementRef.current.nextElementSibling === null });
}