Skip to content

Commit e7e5bd0

Browse files
committed
JSONTagsControls can enter novel values
fix #103
1 parent ec475f8 commit e7e5bd0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

datasette_ui_extras/static/edit-row/JSONTagsControl.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,16 @@ window.JSONTagsControl = class JSONTagsControl {
9090
const json = await rv.json();
9191

9292
const values = json.map(x => x.value);
93-
awesomplete.list = json.map(x => x.value);
93+
94+
let exists = false;
95+
for (const entry of json)
96+
if (entry.value === e.target.value)
97+
exists = true;
98+
99+
awesomplete.list = [
100+
...(exists ? [] : [e.target.value]),
101+
...json.map(x => x.value)
102+
];
94103
awesomplete.evaluate();
95104
});
96105

0 commit comments

Comments
 (0)