fix(structure): focus search shortcut in table structure editor
This commit is contained in:
4 files changed
+35
-7
No files matched your search
@@ -3025,6 +3025,22 @@ function focusIndexSearch() {
|
||||
});
|
||||
}
|
||||
|
||||
function focusSearch(): boolean {
|
||||
if (activeTab.value === "columns") {
|
||||
focusColumnSearch();
|
||||
return true;
|
||||
}
|
||||
if (activeTab.value === "indexes") {
|
||||
focusIndexSearch();
|
||||
return true;
|
||||
}
|
||||
if (activeTab.value === "ddl") {
|
||||
ddlSearchPanelRef.value?.openSearch();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function scrollToIndexSearchMatch(direction: 1 | -1 = 1) {
|
||||
const query = indexSearchText.value.trim();
|
||||
if (!query) {
|
||||
@@ -3653,7 +3669,7 @@ async function applyChanges() {
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ applyChanges });
|
||||
defineExpose({ applyChanges, focusSearch });
|
||||
|
||||
function addItemForActiveTab(): boolean {
|
||||
if (activeTab.value === "columns" && canAddColumn.value) {
|
||||
@@ -3719,10 +3735,10 @@ function onStructureEditorKeydown(event: KeyboardEvent) {
|
||||
return;
|
||||
}
|
||||
if (isPlainModShortcut(event, "f")) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (activeTab.value === "columns") focusColumnSearch();
|
||||
else if (activeTab.value === "ddl") ddlSearchPanelRef.value?.openSearch();
|
||||
if (focusSearch()) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isPlainModShortcut(event, "s")) {
|
||||
|
||||
Vendored
+7
-1
@@ -7,11 +7,17 @@ describe("TableStructureEditor DDL search wiring", () => {
|
||||
it("uses a CodeMirror editor and the shared search panel", () => {
|
||||
expect(source).toContain('import EditorSearchPanel from "@/components/editor/EditorSearchPanel.vue";');
|
||||
expect(source).toContain('key: "Mod-f"');
|
||||
expect(source).toContain('else if (activeTab.value === "ddl") ddlSearchPanelRef.value?.openSearch();');
|
||||
expect(source).toMatch(/if \(activeTab\.value === "ddl"\) \{\s*ddlSearchPanelRef\.value\?\.openSearch\(\);\s*return true;/);
|
||||
expect(source).not.toContain("ddlPreRef");
|
||||
expect(source).not.toContain("onDdlKeydown");
|
||||
});
|
||||
|
||||
it("routes the global search command to the active searchable structure tab", () => {
|
||||
expect(source).toMatch(/function focusSearch\(\): boolean \{[\s\S]*activeTab\.value === "columns"[\s\S]*focusColumnSearch\(\);[\s\S]*activeTab\.value === "indexes"[\s\S]*focusIndexSearch\(\);[\s\S]*activeTab\.value === "ddl"[\s\S]*ddlSearchPanelRef\.value\?\.openSearch\(\)/);
|
||||
expect(source).toContain("defineExpose({ applyChanges, focusSearch });");
|
||||
expect(source).toMatch(/if \(isPlainModShortcut\(event, "f"\)\) \{\s*if \(focusSearch\(\)\)/);
|
||||
});
|
||||
|
||||
it("keeps the DDL editable only where an executable script makes sense", () => {
|
||||
// Editable for an existing table with loaded DDL; the create-table flow has
|
||||
// no DDL tab and an empty baseline only renders a placeholder string, which
|
||||
|
||||
Reference in new issue
Block a user