Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: support keyboard selection (#18063)

ecmadao70349c09edec
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index 2127345b5d..642ed80910 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -42,7 +42,6 @@
:maxlength="65536"
@change="(val: string) => (state.editComment = val)"
@submit="doUpdateComment"
- @cancel="cancelEditComment"
/>
<div
v-if="
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
index 0eb38a54bb..0d4e19c6ef 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
@@ -60,7 +60,6 @@
:project="project"
@change="(val: string) => (state.editContent = val)"
@submit="saveEdit"
- @cancel="cancelEdit"
/>
<div
v-if="state.isEditing"
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index a31f965717..6b538c3cb6 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -46,14 +46,10 @@
:maxlength="maxlength"
@mousedown="clearIssuePanel"
@input="(e: any) => sizeToFit(e.target)"
- @keyup="adjustIssuePanelWithPosition"
+ @keyup="(e: KeyboardEvent) => adjustIssuePanelWithPosition(e)"
@keydown.enter="keyboardHandler"
- @keydown.esc="
- () => {
- $emit('cancel');
- state.content = props.content;
- }
- "
+ @keydown.down="handleArrowDown"
+ @keydown.up="handleArrowUp"
></textarea>
<div
ref="issuePanel"
@@ -62,10 +58,14 @@
<NScrollbar class="max-h-40">
<ul class="text-sm rounded-sm divide-y divide-solid">
<li
- v-for="issue in filterIssueList"
+ v-for="(issue, index) in filterIssueList"
:key="issue.name"
- class="px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-x-2"
+ :class="[
+ 'px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-x-2',
+ { 'bg-gray-100': state.activeIssueIndex === index },
+ ]"
@click="onIssueSelect(issue)"
+ @mouseenter="() => (state.activeIssueIndex = index)"
>
<IssueStatusIcon
:issue-status="issue.status"
@@ -118,6 +118,7 @@ interface LocalState {
showPreview: boolean;
content: string;
activeTab: "write" | "preview";
+ activeIssueIndex?: number;
}
interface Toolbar {
@@ -140,7 +141,6 @@ const props = defineProps<{
const emit = defineEmits<{
(event: "change", value: string): void;
(event: "submit"): void;
- (event: "cancel"): void;
}>();
const state = reactive<LocalState>({
@@ -166,6 +166,24 @@ const contentPreviewArea = ref<HTMLIFrameElement>();
const issuePanel = ref<HTMLDivElement>();
const filterIssueList = ref<ComposedIssue[]>([]);
+watch(
+ () => filterIssueList.value.length,
+ (length) => {
+ if (length === 0) {
+ if (issuePanel.value) {
+ issuePanel.value.style.display = "none";
+ }
+ state.activeIssueIndex = undefined;
+ } else if (contentTextArea.value && issuePanel.value) {
+ const position = getIssuePanelPosition(contentTextArea.value);
+ issuePanel.value.style.display = "block";
+ issuePanel.value.style.left = `${position.x}px`;
+ issuePanel.value.style.top = `${position.y + 25}px`;
+ state.activeIssueIndex = 0;
+ }
+ }
+);
+
const { renderedContent } = useRenderMarkdown(
toRef(state, "content"),
contentPreviewArea,
@@ -231,6 +249,19 @@ const keyboardHandler = (e: KeyboardEvent) => {
if (e.metaKey) {
emit("submit");
} else {
+ if (
+ filterIssueList.value.length > 0 &&
+ state.activeIssueIndex !== undefined
+ ) {
+ const selectedIssue = filterIssueList.value[state.activeIssueIndex];
+ if (selectedIssue) {
+ onIssueSelect(selectedIssue);
+ e.stopPropagation();
+ e.preventDefault();
+ return;
+ }
+ }
+
if (autoComplete(state.content)) {
e.stopPropagation();
e.preventDefault();
@@ -238,6 +269,36 @@ const keyboardHandler = (e: KeyboardEvent) => {
}
};
+const handleArrowDown = (e: KeyboardEvent) => {
+ if (filterIssueList.value.length === 0) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ if (state.activeIssueIndex === undefined) {
+ state.activeIssueIndex = 0;
+ } else if (state.activeIssueIndex < filterIssueList.value.length - 1) {
+ state.activeIssueIndex++;
+ }
+};
+
+const handleArrowUp = (e: KeyboardEvent) => {
+ if (filterIssueList.value.length === 0) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ if (state.activeIssueIndex === undefined) {
+ state.activeIssueIndex = 0;
+ } else if (state.activeIssueIndex > 0) {
+ state.activeIssueIndex--;
+ }
+};
+
const autoComplete = (text: string) => {
if (!contentTextArea.value) {
return false;
@@ -411,9 +472,6 @@ const insertWithCursorPosition = (template: string, position: number) => {
};
const clearIssuePanel = () => {
- if (issuePanel.value) {
- issuePanel.value.style.display = "none";
- }
filterIssueList.value = [];
};
@@ -470,7 +528,15 @@ const issueTaskStatus = (issue: ComposedIssue) => {
return activeTaskInRollout(issue.rolloutEntity)?.status;
};
-const adjustIssuePanelWithPosition = useDebounceFn(() => {
+const adjustIssuePanelWithPosition = useDebounceFn((e?: KeyboardEvent) => {
+ if (
+ e &&
+ (e.key === "ArrowDown" || e.key === "ArrowUp") &&
+ filterIssueList.value.length > 0
+ ) {
+ return;
+ }
+
if (!contentTextArea.value || !issuePanel.value) {
return;
}
@@ -511,11 +577,6 @@ const adjustIssuePanelWithPosition = useDebounceFn(() => {
filterIssueList.value = resp.issues;
}
});
-
- const position = getIssuePanelPosition(contentTextArea.value);
- issuePanel.value.style.display = "block";
- issuePanel.value.style.left = `${position.x}px`;
- issuePanel.value.style.top = `${position.y + 25}px`;
}, DEBOUNCE_SEARCH_DELAY);
const getIssuePanelPosition = (textArea: HTMLTextAreaElement) => {