-
-
Notifications
You must be signed in to change notification settings - Fork 17
Fix chat focus behavior to allow copy/paste from messages #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nakul-py for working on this.
I have some comment below, let me know if it sound reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Wondering if we really need to force the focus to the chat area at all? As a user, it can be frustrating if the application forces the focus to be somewhere else than where we want it to be. |
This behavior has been added in #146. The idea was to update the focus tracker on click, to make the commands work on the last clicked chat. To update the focus tracker, we need to focus an element of the chat. By default, the input field seemed to be the most relevant element to focus on. |
| if ( | ||
| target.closest('button, a, input, textarea, select, summary, details') | ||
| ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking again about it, a more generic way could be to check if the current active element is on the chat, instead of checking if the target isl focusable element. Something like:
| if ( | |
| target.closest('button, a, input, textarea, select, summary, details') | |
| ) { | |
| return; | |
| } | |
| if (this.node.contains(document.activeElement)) { | |
| return; | |
| } |
That way we ensure that the input get focussed (and the tracker updates the current chat) only if the click occurs in a non-focusable element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds Good!🙂 and i have tried it working fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nakul-py for updating it quickly.
Previously, clicking anywhere in the chat panel forced focus onto the input (
this.node.onclick = () => this.model.input.focus();). This made it difficult to select or copy text from the chat history, since every click redirected focus.Now we check if the user has selected text input loses focus, click on
button,interactive elements,<details>,<summary>and else work like beforeScreencast.From.2025-09-09.13-16-45.mp4
Closes #267