mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 15:25:59 +00:00
prevent jump to first item when focusing because of mouse
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
let isListFocused = false;
|
||||
let domDiv = null;
|
||||
let lastInputMethod = null;
|
||||
export let hideContent = false;
|
||||
|
||||
function handleKeyDown(ev) {
|
||||
@@ -25,6 +26,11 @@
|
||||
const selected = getSelectedObject();
|
||||
const index = _.findIndex(listInstance, x => selectedObjectMatcher(x, selected));
|
||||
|
||||
if (index < 0) {
|
||||
focusFirst();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == 0 && diff < 0) {
|
||||
onFocusFilterBox?.();
|
||||
return;
|
||||
@@ -115,12 +121,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFocus() {
|
||||
async function handleFocus(e) {
|
||||
isListFocused = true;
|
||||
|
||||
// await tick();
|
||||
await sleep(100);
|
||||
// console.log('ON FOCUS AFTER SLEEP');
|
||||
if (lastInputMethod == 'mouse') {
|
||||
return;
|
||||
}
|
||||
|
||||
const listInstance = _.isFunction(list) ? list() : list;
|
||||
const selected = getSelectedObject();
|
||||
const index = _.findIndex(listInstance, x => selectedObjectMatcher(x, selected));
|
||||
@@ -139,6 +146,15 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
on:keydown={() => {
|
||||
lastInputMethod = 'keyboard';
|
||||
}}
|
||||
on:mousedown={() => {
|
||||
lastInputMethod = 'mouse';
|
||||
}}
|
||||
/>
|
||||
|
||||
<div
|
||||
tabindex="0"
|
||||
on:keydown={handleKeyDown}
|
||||
|
||||
Reference in New Issue
Block a user