From 324ff317cbdd13e85c1af15606b6c73557432b8f Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 27 Apr 2023 18:35:25 +0700 Subject: [PATCH] TSK-571: Fix keyboard list navigation (#3085) Signed-off-by: Andrey Sobolev --- .../kanban/src/components/KanbanRow.svelte | 22 +++-- .../src/components/MessageBox.svelte | 8 +- .../src/components/StyledTextBox.svelte | 17 ++++ .../src/components/StyledTextEditor.svelte | 2 +- packages/ui/src/colors.ts | 60 +++++++++--- .../ui/src/components/FocusHandler.svelte | 2 +- packages/ui/src/focus.ts | 3 + packages/ui/src/utils.ts | 21 ++--- .../src/components/AttachmentStyledBox.svelte | 2 + .../src/components/AssigneeBox.svelte | 2 +- .../src/components/TagsPopup.svelte | 2 + .../src/components/ComponentSelector.svelte | 3 + .../src/components/CreateIssue.svelte | 43 ++++++++- .../src/components/icons/StatusIcon.svelte | 2 + .../components/issues/AssigneeEditor.svelte | 2 + .../components/issues/PriorityEditor.svelte | 2 + .../src/components/issues/StatusEditor.svelte | 11 ++- .../issues/timereport/EstimationEditor.svelte | 2 + .../components/sprints/SprintSelector.svelte | 3 + .../components/ViewletSettingButton.svelte | 9 +- .../src/components/list/List.svelte | 8 +- .../src/components/list/ListCategories.svelte | 94 +++++++++++++++---- .../src/components/list/ListCategory.svelte | 42 +++++---- .../src/components/list/ListHeader.svelte | 45 +++++++-- plugins/view-resources/src/selection.ts | 15 ++- 25 files changed, 330 insertions(+), 92 deletions(-) diff --git a/packages/kanban/src/components/KanbanRow.svelte b/packages/kanban/src/components/KanbanRow.svelte index 40a750fa08..d6766fefaf 100644 --- a/packages/kanban/src/components/KanbanRow.svelte +++ b/packages/kanban/src/components/KanbanRow.svelte @@ -57,18 +57,22 @@ let limitedObjects: DocWithRank[] = [] let loading = false + let loadingTimeout: any | undefined = undefined - function nop (op: () => void, timeout: number) { - op() - } - - $: { - loading = true - ;(limitedObjects.length > 0 ? nop : setTimeout)(() => { + function update (stateObjects: Item[], limit: number | undefined, index: number): void { + clearTimeout(loadingTimeout) + if (limitedObjects.length > 0 || index * 2 === 0) { limitedObjects = stateObjects.slice(0, limit) - loading = false - }, index * 2) + } else { + loading = true + loadingTimeout = setTimeout(() => { + limitedObjects = stateObjects.slice(0, limit) + loading = false + }, index * 2) + } } + + $: update(stateObjects, limit, index) {#each limitedObjects as object, i (object._id)} diff --git a/packages/presentation/src/components/MessageBox.svelte b/packages/presentation/src/components/MessageBox.svelte index 753fed0024..f46919033d 100644 --- a/packages/presentation/src/components/MessageBox.svelte +++ b/packages/presentation/src/components/MessageBox.svelte @@ -14,8 +14,8 @@ --> + +
{/if}
@@ -183,9 +215,8 @@ &.gradient::before { background: linear-gradient( 90deg, - rgba(var(--list-header-rgb-color), 0.5), - rgba(var(--list-header-rgb-color), 0.3), - rgba(var(--list-header-rgb-color), 0.1) + rgba(var(--list-header-rgb-color), 0.15), + rgba(var(--list-header-rgb-color), 0.05) ); } &::before, diff --git a/plugins/view-resources/src/selection.ts b/plugins/view-resources/src/selection.ts index 98db2269cb..c8f907153c 100644 --- a/plugins/view-resources/src/selection.ts +++ b/plugins/view-resources/src/selection.ts @@ -1,7 +1,7 @@ import { Doc } from '@hcengineering/core' import { panelstore } from '@hcengineering/ui' import { onDestroy } from 'svelte' -import { Unsubscriber, writable } from 'svelte/store' +import { Unsubscriber, derived, writable } from 'svelte/store' /** * @public @@ -50,8 +50,17 @@ export interface FocusSelection { * @public */ export const focusStore = writable({}) + +/** + * @public + */ export const selectionStore = writable([]) +/** + * @public + */ +export const selectionStoreMap = derived(selectionStore, (it) => new Set(it.map((it) => it._id))) + export const previewDocument = writable() panelstore.subscribe((val) => { @@ -61,6 +70,10 @@ panelstore.subscribe((val) => { * @public */ export function updateFocus (selection?: FocusSelection): void { + if (!window.document.hasFocus()) { + window.focus() + } + focusStore.update((cur) => { const now = Date.now()