Skip to content

Commit

Permalink
Message: Only focus if focus is not inside container already
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Nov 15, 2019
1 parent 8b239b7 commit 79b9408
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ts/components/conversation/InlineNotificationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand Down
6 changes: 4 additions & 2 deletions ts/components/conversation/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand Down

0 comments on commit 79b9408

Please sign in to comment.