Skip to content

Commit

Permalink
feat: auto close dropdown
Browse files Browse the repository at this point in the history
closes #19
  • Loading branch information
linonetwo committed May 15, 2024
1 parent dffb6ef commit 7f13227
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/super-tag/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare module '$:/plugins/linonetwo/super-tag/utils/initEditor.js' {

declare module '@json-editor/json-editor' {
// copy from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-editor/index.d.ts
// add `hideAddProperty`

interface JSONEditorOptions<TValue> {
/**
Expand Down Expand Up @@ -163,6 +164,12 @@ declare module '@json-editor/json-editor' {
resolvers: Array<(schema: any) => string>;
};

editors: {
SuperTag: {
hideAddProperty(): void;
}
}

public static plugins: {
ace: {
theme: string;
Expand Down
5 changes: 5 additions & 0 deletions src/super-tag/widgets/utils/formOnChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export function formOnChange(currentTiddlerTitle?: string, editor?: JSONEditor.J
tiddlerFields = tiddlerFieldsWithoutKey;
delete latestFormValue[key];
}
// if it was empty, and user add a new property, close the dialog
if (tiddlerFields[key] === undefined && key in latestFormValue) {
// based on `form_name_root`
editor.editors.SuperTag.hideAddProperty();
}
}
});
if (hasChange) {
Expand Down

0 comments on commit 7f13227

Please sign in to comment.