Skip to content

CB-1698 catch and restore focus on element#1491

Merged
Wroud merged 1 commit intodevelfrom
CB-1698-keep-cursor-in-the-sql-editor-after-closing-popup-dialog
Feb 27, 2023
Merged

CB-1698 catch and restore focus on element#1491
Wroud merged 1 commit intodevelfrom
CB-1698-keep-cursor-in-the-sql-editor-after-closing-popup-dialog

Conversation

@tfokina
Copy link
Copy Markdown
Contributor

@tfokina tfokina commented Feb 21, 2023

No description provided.

@tfokina tfokina requested review from Wroud and devnaumov February 21, 2023 18:05
@tfokina tfokina self-assigned this Feb 21, 2023
Comment on lines +69 to +77
useEffect(() => {
if (document.activeElement instanceof HTMLElement) {
focusedElementRef.current = document.activeElement;
}

return () => {
focusedElementRef.current?.focus();
};
}, []);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  useEffect(() => {
    let previousFocus: HTMLElement | undefined; 
    if (document.activeElement instanceof HTMLElement) {
      previousFocus = document.activeElement;
    }

    return () => {
      previousFocus.focus();
    };
  }, []);

shorter equivalent

@Wroud Wroud merged commit d7c1c26 into devel Feb 27, 2023
@Wroud Wroud deleted the CB-1698-keep-cursor-in-the-sql-editor-after-closing-popup-dialog branch February 27, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants