Fixed #3435 - MultiSelect: mark text with shift+Home does not work

pull/3509/head
mertsincan 2023-01-09 13:06:17 +00:00
parent 61508e656c
commit 705f7e796c
2 changed files with 16 additions and 21 deletions

View File

@ -663,29 +663,19 @@ export default {
this.multiple && event.stopPropagation(); // To prevent onArrowRightKeyOnMultiple method this.multiple && event.stopPropagation(); // To prevent onArrowRightKeyOnMultiple method
}, },
onHomeKey(event) { onHomeKey(event) {
const target = event.currentTarget; const { currentTarget } = event;
const len = target.value.length; const len = currentTarget.value.length;
if (event.shiftKey) {
event.currentTarget.setSelectionRange(0, len);
} else {
event.currentTarget.setSelectionRange(0, 0);
}
currentTarget.setSelectionRange(0, event.shiftKey ? len : 0);
this.focusedOptionIndex = -1; this.focusedOptionIndex = -1;
event.preventDefault(); event.preventDefault();
}, },
onEndKey(event) { onEndKey(event) {
const target = event.currentTarget; const { currentTarget } = event;
const len = target.value.length; const len = currentTarget.value.length;
if (event.shiftKey) {
event.currentTarget.setSelectionRange(0, len);
} else {
target.setSelectionRange(len, len);
}
currentTarget.setSelectionRange(event.shiftKey ? 0 : len, len);
this.focusedOptionIndex = -1; this.focusedOptionIndex = -1;
event.preventDefault(); event.preventDefault();

View File

@ -660,8 +660,12 @@ export default {
pressedInInputText && (this.focusedOptionIndex = -1); pressedInInputText && (this.focusedOptionIndex = -1);
}, },
onHomeKey(event, pressedInInputText = false) { onHomeKey(event, pressedInInputText = false) {
const { currentTarget } = event;
if (pressedInInputText) { if (pressedInInputText) {
event.currentTarget.setSelectionRange(0, 0); const len = currentTarget.value.length;
currentTarget.setSelectionRange(0, event.shiftKey ? len : 0);
this.focusedOptionIndex = -1; this.focusedOptionIndex = -1;
} else { } else {
let metaKey = event.metaKey || event.ctrlKey; let metaKey = event.metaKey || event.ctrlKey;
@ -679,11 +683,12 @@ export default {
event.preventDefault(); event.preventDefault();
}, },
onEndKey(event, pressedInInputText = false) { onEndKey(event, pressedInInputText = false) {
if (pressedInInputText) { const { currentTarget } = event;
const target = event.currentTarget;
const len = target.value.length;
target.setSelectionRange(len, len); if (pressedInInputText) {
const len = currentTarget.value.length;
currentTarget.setSelectionRange(event.shiftKey ? 0 : len, len);
this.focusedOptionIndex = -1; this.focusedOptionIndex = -1;
} else { } else {
let metaKey = event.metaKey || event.ctrlKey; let metaKey = event.metaKey || event.ctrlKey;