mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
chore(react/ribbon): focus on search textbox
This commit is contained in:
parent
b9193a5562
commit
3f105f7b8b
@ -85,7 +85,6 @@ export type CommandMappings = {
|
||||
focusTree: CommandData;
|
||||
focusOnTitle: CommandData;
|
||||
focusOnDetail: CommandData;
|
||||
focusOnSearchDefinition: Required<CommandData>;
|
||||
searchNotes: CommandData & {
|
||||
searchString?: string;
|
||||
ancestorNoteId?: string | null;
|
||||
|
@ -43,8 +43,6 @@ export default class RootCommandExecutor extends Component {
|
||||
const noteContext = await appContext.tabManager.openTabWithNoteWithHoisting(searchNote.noteId, {
|
||||
activate: true
|
||||
});
|
||||
|
||||
appContext.triggerCommand("focusOnSearchDefinition", { ntxId: noteContext.ntxId });
|
||||
}
|
||||
|
||||
async searchInSubtreeCommand({ notePath }: CommandListenerData<"searchInSubtree">) {
|
||||
|
@ -254,6 +254,9 @@ function SearchStringOption({ note, refreshResults, error, ...restProps }: Searc
|
||||
placement: "bottom"
|
||||
});
|
||||
|
||||
// Auto-focus.
|
||||
useEffect(() => inputRef.current?.focus(), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
showTooltip();
|
||||
|
@ -1,18 +0,0 @@
|
||||
import AbstractSearchOption from "./abstract_search_option.js";
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import server from "../../services/server.js";
|
||||
import shortcutService from "../../services/shortcuts.js";
|
||||
import appContext, { type EventData } from "../../components/app_context.js";
|
||||
import { t } from "../../services/i18n.js";
|
||||
import { Tooltip } from "bootstrap";
|
||||
|
||||
export default class SearchString extends AbstractSearchOption {
|
||||
|
||||
focusOnSearchDefinitionEvent() {
|
||||
this.$searchString
|
||||
.val(String(this.$searchString.val()).trim() ?? appContext.lastSearchString)
|
||||
.focus()
|
||||
.select();
|
||||
this.spacedUpdate.scheduleUpdate();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user