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 final;
let scrollPx;
let direction = 'none';
if (isHome) {
begin = 0;
final = shiftKey ? cur : begin;
scrollPx = 0;
direction = 'backward';
} else {
final = elem.value.length;
begin = shiftKey ? cur : final;
scrollPx = elem.scrollWidth - elem.clientWidth;
}
elem.setSelectionRange(begin, final);
elem.setSelectionRange(begin, final, direction);
elem.scrollLeft = scrollPx;
return true;
}