summaryrefslogtreecommitdiffstats
path: root/client/lib/textComplete.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-10-31 10:27:20 +0100
committerMaxime Quandalle <maxime@quandalle.com>2015-10-31 12:49:58 +0100
commit2b134ff7a986eb97f8ec360321be284a7a8ea11e (patch)
tree0ff579909b402db5916b66ec7bc7469534881a15 /client/lib/textComplete.js
parent3507c6565bb16b5f45c6f269f7376902f8b1ff37 (diff)
parent41b23f88aea0f421226f92b081cdb1b61c64bde4 (diff)
downloadwekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.tar.gz
wekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.tar.bz2
wekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.zip
Merge branch 'devel' into minicard-editor
Conflicts: client/components/lists/listBody.js
Diffstat (limited to 'client/lib/textComplete.js')
-rw-r--r--client/lib/textComplete.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/client/lib/textComplete.js b/client/lib/textComplete.js
new file mode 100644
index 00000000..e50d7cbc
--- /dev/null
+++ b/client/lib/textComplete.js
@@ -0,0 +1,30 @@
+// We “inherit” the jquery-textcomplete plugin to integrate with our
+// EscapeActions system. You should always use `escapeableTextComplete` instead
+// of the vanilla `textcomplete`.
+let dropdownMenuIsOpened = false;
+
+$.fn.escapeableTextComplete = function(...args) {
+ this.textcomplete(...args);
+
+ // Since commit d474017 jquery-textComplete automatically closes a potential
+ // opened dropdown menu when the user press Escape. This behavior conflicts
+ // with our EscapeActions system, but it's too complicated and hacky to
+ // monkey-pach textComplete to disable it -- I tried. Instead we listen to
+ // 'open' and 'hide' events, and create a ghost escapeAction when the dropdown
+ // is opened (and rely on textComplete to execute the actual action).
+ this.on({
+ 'textComplete:show'() {
+ dropdownMenuIsOpened = true;
+ },
+ 'textComplete:hide'() {
+ Tracker.afterFlush(() => {
+ dropdownMenuIsOpened = false;
+ });
+ },
+ });
+};
+
+EscapeActions.register('textcomplete',
+ () => {},
+ () => dropdownMenuIsOpened
+);