Skip to content

Commit

Permalink
fix: layout not closed after tap
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Sep 23, 2024
1 parent 3783c97 commit 0e52ee6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/autocomplete/widgets/build-in-sub-plugins/search-layout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
import { AutocompleteState } from '@algolia/autocomplete-core';
import type { AutocompletePlugin } from '@algolia/autocomplete-js';
import { ITiddlerFields } from 'tiddlywiki';
import { checkIsSearchSystem, checkIsUnderFilter } from '../utils/checkPrefix';
Expand All @@ -18,8 +19,9 @@ export const plugin = {
if (parameters.query.length === 0) return [];
if (!checkIsSearchSystem(parameters) || checkIsUnderFilter(parameters)) return [];
const { widget } = parameters.state.context as IContext;
const onSelect = (item: ITiddlerFields) => {
const onSelect = (item: ITiddlerFields, state: AutocompleteState<ITiddlerFields>) => {
parameters.setContext({ noNavigate: true } satisfies IContext);
parameters.navigator.navigate({ item, itemUrl: item.title, state });
$tw.wiki.setText('$:/layout', 'text', undefined, item.title, { suppressTimestamp: true });
};
return [
Expand All @@ -45,8 +47,8 @@ export const plugin = {
getItemUrl({ item }) {
return item.title;
},
onSelect({ item }) {
onSelect(item);
onSelect({ item, state }) {
onSelect(item, state);
},
templates: {
header() {
Expand All @@ -57,9 +59,9 @@ export const plugin = {
: $tw.wiki.getTiddlerText('$:/language/PageTemplate/Name');
return `${lingo('Layout')} - ${lingo('CurrentLayout')}: ${currentLayoutName}`;
},
item({ item, createElement }) {
item({ item, createElement, state }) {
const onclick = () => {
onSelect(item);
onSelect(item, state);
};
if (typeof item.name === 'string' && item.name !== '') {
const name = renderTextWithCache(item.name, widget);
Expand Down

0 comments on commit 0e52ee6

Please sign in to comment.