Skip to content

Commit 0e2180c

Browse files
committed
[academic_query] _fix_ focus switch on editing queries
SQUASHED: AUTO-COMMIT-src-components-widgets-academic-subquery.js,
1 parent eb729dd commit 0e2180c

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/components/widgets/academic-subquery.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ s.addOperation(
123123
)
124124

125125
var observer;
126+
var timeout;
126127

127128
export default class AcademicSubquery extends Morph {
128129
constructor() {
@@ -133,17 +134,21 @@ export default class AcademicSubquery extends Morph {
133134
this.updateView()
134135

135136
observer = new MutationObserver((mutations) => {
136-
mutations.forEach(async mutation => {
137-
if (mutation.type == "characterData") {
138-
this.textContent = await this.viewToQuery();
139-
}
140-
if (mutation.type == "childList") {
141-
// TODO: better propagation to super elements
142-
var div = <div id="update"></div>;
143-
this.appendChild(div);
144-
this.removeChild(div);
145-
}
146-
})
137+
clearTimeout(timeout);
138+
timeout = setTimeout(async () => {
139+
mutations.forEach(async mutation => {
140+
if (mutation.type == "characterData") {
141+
this.textContent = await this.viewToQuery();
142+
}
143+
if (mutation.type == "childList") {
144+
// TODO: better propagation to super elements
145+
var div = <div id="update"></div>;
146+
this.appendChild(div);
147+
this.removeChild(div);
148+
149+
}
150+
})
151+
}, 300);
147152
});
148153

149154
const config = {
@@ -290,13 +295,10 @@ export default class AcademicSubquery extends Morph {
290295
.map(e => e.textContent);
291296
if (val)
292297
val = val.slice(0, val.length - 1); // remove last whitespace
293-
// TODO: keep the '' when parsing query so that we don't have
294-
// 3 spans here....
295-
// OOODER ich lass das mit dem Edit Mode, dafür gibt's ja schon
296-
// das input Feld
297298

298299
// TODO check if attribute has string value
299-
if (attr.slice(0, attr.length - 1) == "A") {
300+
var stringAttributes = {A: "Author"}
301+
if (attr.slice(0, attr.length - 1) in stringAttributes) {
300302
val = "'" + val + "'"
301303
}
302304
//query = attr + comp + "'" + val + "'";

0 commit comments

Comments
 (0)