mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Abstract the jquery-textcomplete integration with EscapeActions
We now can re-use this integration in multiple places, this will be useful for #342 for instance.
This commit is contained in:
parent
e504ac2894
commit
8bbc69616f
3 changed files with 32 additions and 26 deletions
30
client/lib/textComplete.js
Normal file
30
client/lib/textComplete.js
Normal file
|
|
@ -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
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue