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

AutoComplete: mark text with shift+Home does not work. #3140

Closed
Rakasch opened this issue Oct 20, 2022 · 7 comments
Closed

AutoComplete: mark text with shift+Home does not work. #3140

Rakasch opened this issue Oct 20, 2022 · 7 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Rakasch
Copy link
Contributor

Rakasch commented Oct 20, 2022

Describe the bug

If you set the cursor in the text field at the end of the text, you can usually use the keyboard shortcut Shift+Pos1 to select the whole text in the text field.
This works in the InpuText Component.
Unfortunately it does not work in the AutoComplete Component.

Reproducer

https://www.primefaces.org/primevue/autocomplete

PrimeVue version

3.17.0

Vue version

3.x

Language

ES6

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

Go to https://www.primefaces.org/primevue/autocomplete
Enter some Text into an autocomplete
set cursor at end of text
hit Shift+Pos1
the cursor only jumps to the start of the string.

Expected behavior

I expect the text to be highlighted.
just like in the InputText component.
image

@Rakasch Rakasch added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Oct 20, 2022
@Rakasch Rakasch changed the title AutoComplete: mark text with shift+pos1 does not word. AutoComplete: mark text with shift+pos1 does not work. Oct 20, 2022
@mertsincan
Copy link
Member

Hi,

Unfortunately, I don't have a keyboard that supports Pos1 key. A PR from your side on this topic would be excellent.

@mertsincan mertsincan added the Resolution: Help Wanted Issue or pull request requires extra help and feedback label Oct 20, 2022
@Rakasch
Copy link
Contributor Author

Rakasch commented Oct 20, 2022

I checked, the event.code for the key says "Home".

The same issue exists, when the cursor is at first pos and you hit Shift+End.

@Rakasch
Copy link
Contributor Author

Rakasch commented Oct 20, 2022

could be fixed this way for the Home key.
equivalent for the End key.

`onHomeKey(event) {
const target = event.currentTarget;
const len = target.value.length;

        if(event.shiftKey){
            event.currentTarget.setSelectionRange(0, len);
        }else{
            event.currentTarget.setSelectionRange(0, 0);
        }

        this.focusedOptionIndex = -1;

        event.preventDefault();
    },`

@Rakasch Rakasch changed the title AutoComplete: mark text with shift+pos1 does not work. AutoComplete: mark text with shift+Home does not work. Oct 20, 2022
@bahadirsofuoglu
Copy link
Contributor

Hi,
When I try the Home shortcut for Input Text and AutoComplete in the same scenario, I see the same behavior. Could be something I missed? Thank you.

@Rakasch
Copy link
Contributor Author

Rakasch commented Oct 21, 2022

Not Home, but Shift and Home.
Shift+Home in InputText component highlightes the text.
Shift+Home in AutoComplete component does not highlight the text, it only jumps to the start of the text.

The code of AutoComplete explicitly sets the selection to zero.
event.currentTarget.setSelectionRange(0, 0);

InputText Component highlighted text after Shift+Home:
image

Just add an if case for event.shiftKey:

if(event.shiftKey){
    event.currentTarget.setSelectionRange(0, len);
}else{
    event.currentTarget.setSelectionRange(0, 0);
}

@bahadirsofuoglu bahadirsofuoglu self-assigned this Oct 21, 2022
@Rakasch
Copy link
Contributor Author

Rakasch commented Oct 21, 2022

equivalent for the Shift+End combination.

@tugcekucukoglu tugcekucukoglu removed the Resolution: Help Wanted Issue or pull request requires extra help and feedback label Oct 25, 2022
@tugcekucukoglu tugcekucukoglu added this to the 3.18.1 milestone Oct 25, 2022
@tugcekucukoglu
Copy link
Member

Fixed #3142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants