mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 10:06:00 +00:00
focusable databases WIP
This commit is contained in:
@@ -15,9 +15,11 @@
|
||||
let domDiv = null;
|
||||
|
||||
function handleKeyDown(ev) {
|
||||
const listInstance = _.isFunction(list) ? list() : list;
|
||||
|
||||
function selectByDiff(diff) {
|
||||
const selected = getSelectedObject();
|
||||
const index = _.findIndex(list, x => selectedObjectMatcher(x, selected));
|
||||
const index = _.findIndex(listInstance, x => selectedObjectMatcher(x, selected));
|
||||
|
||||
if (index == 0 && diff < 0) {
|
||||
onFocusFilterBox?.();
|
||||
@@ -26,16 +28,16 @@
|
||||
|
||||
if (index >= 0) {
|
||||
let newIndex = index + diff;
|
||||
if (newIndex >= list.length) {
|
||||
newIndex = list.length - 1;
|
||||
if (newIndex >= listInstance.length) {
|
||||
newIndex = listInstance.length - 1;
|
||||
}
|
||||
if (newIndex < 0) {
|
||||
newIndex = 0;
|
||||
}
|
||||
|
||||
if (list[newIndex]) {
|
||||
selectedObjectStore.set(list[newIndex]);
|
||||
handleObjectClick?.(list[newIndex], { tabPreviewMode: true });
|
||||
if (listInstance[newIndex]) {
|
||||
selectedObjectStore.set(listInstance[newIndex]);
|
||||
handleObjectClick?.(listInstance[newIndex], { tabPreviewMode: true });
|
||||
}
|
||||
|
||||
if (newIndex == 0) {
|
||||
@@ -64,25 +66,27 @@
|
||||
ev.preventDefault();
|
||||
}
|
||||
if (ev.keyCode == keycodes.home) {
|
||||
if (list[0]) {
|
||||
selectedObjectStore.set(list[0]);
|
||||
handleObjectClick?.(list[0], { tabPreviewMode: true });
|
||||
if (listInstance[0]) {
|
||||
selectedObjectStore.set(listInstance[0]);
|
||||
handleObjectClick?.(listInstance[0], { tabPreviewMode: true });
|
||||
onScrollTop?.();
|
||||
}
|
||||
}
|
||||
if (ev.keyCode == keycodes.end) {
|
||||
if (list[list.length - 1]) {
|
||||
selectedObjectStore.set(list[list.length - 1]);
|
||||
handleObjectClick?.(list[list.length - 1], { tabPreviewMode: true });
|
||||
if (listInstance[listInstance.length - 1]) {
|
||||
selectedObjectStore.set(listInstance[listInstance.length - 1]);
|
||||
handleObjectClick?.(listInstance[listInstance.length - 1], { tabPreviewMode: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function focusFirst() {
|
||||
const listInstance = _.isFunction(list) ? list() : list;
|
||||
|
||||
domDiv?.focus();
|
||||
if (list[0]) {
|
||||
selectedObjectStore.set(list[0]);
|
||||
handleObjectClick?.(list[0], { tabPreviewMode: true });
|
||||
if (listInstance[0]) {
|
||||
selectedObjectStore.set(listInstance[0]);
|
||||
handleObjectClick?.(listInstance[0], { tabPreviewMode: true });
|
||||
onScrollTop?.();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user