Message: Only focus if focus is not inside container already
This commit is contained in:
parent
8b239b76ef
commit
79b9408f1f
2 changed files with 8 additions and 4 deletions
|
@ -11,8 +11,10 @@ export class InlineNotificationWrapper extends React.Component<PropsType> {
|
|||
public focusRef: React.RefObject<HTMLDivElement> = React.createRef();
|
||||
|
||||
public setFocus = () => {
|
||||
if (this.focusRef.current) {
|
||||
this.focusRef.current.focus();
|
||||
const container = this.focusRef.current;
|
||||
|
||||
if (container && !container.contains(document.activeElement)) {
|
||||
container.focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -187,8 +187,10 @@ export class Message extends React.PureComponent<Props, State> {
|
|||
};
|
||||
|
||||
public setFocus = () => {
|
||||
if (this.focusRef.current) {
|
||||
this.focusRef.current.focus();
|
||||
const container = this.focusRef.current;
|
||||
|
||||
if (container && !container.contains(document.activeElement)) {
|
||||
container.focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue