Skip to content
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

Allow default input behavior for text selection on TagsInput and Combobox #1318

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michgeek
Copy link

When typing inside the input of a combobox or tagsinput it should be allowed to select that text with shift + either left, right, home or end.

The current behavior is preventing the combination of shift+end and shift+home.

Comment on lines 175 to 178
// allow text selection while maintaining `shift` key
if(event.shiftKey)
break

Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need it for Tags Input. The current implementation works well, where we only focus on TagsInputItem when we are not highlighting any text

Screen.Recording.2024-10-01.at.9.30.46.PM.mov

Copy link
Author

Choose a reason for hiding this comment

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

I believe you used arrows to select char one by one. This one enables text selection in its entirety or what's left of it with shift+home or shift+end. That is the expected behaviour when using a text input.

This comment was marked as outdated.

Copy link
Author

Choose a reason for hiding this comment

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

What about the following behavior ? I removed the tests I wrote because I think they're not great and couldn't figure it out.

Screencast.from.2024-10-02.21-52-00.webm
Screencast.from.2024-10-02.21-55-07.webm

@michgeek michgeek changed the title Allow text selection within input tag using Shift + Home or Shift + End Allow default of input text selection on TagsInput and Combobox Oct 2, 2024
@michgeek michgeek changed the title Allow default of input text selection on TagsInput and Combobox Allow default input behavior for text selection on TagsInput and Combobox Oct 3, 2024
Comment on lines +177 to +180

// prevent tag focus when there's something in the input
// the user must clear the input if he needs to clear already added tags
if (target.value.length > 0)
Copy link
Member

Choose a reason for hiding this comment

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

This is not the behavior we want. We want to allow user to focus on tags even when there's input value.

Copy link
Author

Choose a reason for hiding this comment

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

I understand that's the behavior you intended. However, it's hijacking the default behavior of a text input. Its purpose is to allow a user to enter a new value or perform a search, therefore it is reasonable to expect it to behave like a normal text input.

From a user's perspective, typing indicates the intention of adding or searching.
Therefore while he is typing, he should be able to select it as he normally would. That intention should be prioritized over the intention of focusing tags that were already added.

I believe you should reconsider this behavior. Otherwise feel free to close the PR.

Many thanks

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