Wunderbar: handle 'shift+home' key not highlighting text

## Issue
- Patch for 5316: "Home and End keys not working in search box"

## Notes
Seems like 'shift+home' wasn't highlighting the text. 'shift+end' works.

Was pretty sure I tested that previously. Anyway, adding the direction variable seems to fix it.
This commit is contained in:
infinite-persistence 2021-04-12 00:07:25 +08:00 committed by Sean Yesmunt
parent 294866fb4b
commit 3406c2f800

View file

@ -134,18 +134,20 @@ export default function WunderBarSuggestions(props: Props) {
let begin; let begin;
let final; let final;
let scrollPx; let scrollPx;
let direction = 'none';
if (isHome) { if (isHome) {
begin = 0; begin = 0;
final = shiftKey ? cur : begin; final = shiftKey ? cur : begin;
scrollPx = 0; scrollPx = 0;
direction = 'backward';
} else { } else {
final = elem.value.length; final = elem.value.length;
begin = shiftKey ? cur : final; begin = shiftKey ? cur : final;
scrollPx = elem.scrollWidth - elem.clientWidth; scrollPx = elem.scrollWidth - elem.clientWidth;
} }
elem.setSelectionRange(begin, final); elem.setSelectionRange(begin, final, direction);
elem.scrollLeft = scrollPx; elem.scrollLeft = scrollPx;
return true; return true;
} }