diff options
| author | Alexandre Kühn <aku@odoo.com> | 2019-09-12 09:00:39 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2019-09-12 09:26:06 +0000 |
| commit | 057d3eba2e07fd035a826f5eeed651149ced469f (patch) | |
| tree | 4bd4b585ac43f6c0bb0a4631a6ab91bf0c477f35 /addons/web/static/src/js/widgets | |
| parent | 0fdc914a67bc81d3b9fd64895a3808cb3b46baa7 (diff) | |
[FIX] web: use search view input with composition mode
Forward-port of #36688 (original: #36284)
Before this commit, search view was barely usable with Japanese IME.
For instance, when pressing ENTER while in composition mode and
IME prompts some suggestions, it made a search with the updated input
content. The expected behaviour should have been to update the input
content, without making the search yet.
This commit fixes the issue by turning off some actions of the
search view when typing during composition mode.
opw-2061590
closes odoo/odoo#36728
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/widgets')
| -rw-r--r-- | addons/web/static/src/js/widgets/auto_complete.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/addons/web/static/src/js/widgets/auto_complete.js b/addons/web/static/src/js/widgets/auto_complete.js index 1bb00be8d38..30c38690d17 100644 --- a/addons/web/static/src/js/widgets/auto_complete.js +++ b/addons/web/static/src/js/widgets/auto_complete.js @@ -29,16 +29,23 @@ return Widget.extend({ this.searching = true; this.search_string = ''; this.current_search = null; + this._isInputComposing = false; }, start: function () { var self = this; + this.$input.on('compositionend', function (ev) { + self._isInputComposing = false; + }); + this.$input.on('compositionstart', function (ev) { + self._isInputComposing = true; + }); this.$input.on('keyup', function (ev) { - if (ev.which === $.ui.keyCode.RIGHT) { + if (ev.which === $.ui.keyCode.RIGHT && !self._isInputComposing) { self.searching = true; ev.preventDefault(); return; } - if (ev.which === $.ui.keyCode.ENTER) { + if (ev.which === $.ui.keyCode.ENTER && !self._isInputComposing) { if (self.search_string.length) { self.select_item(ev); } @@ -68,6 +75,9 @@ return Widget.extend({ } }); this.$input.on('keydown', function (ev) { + if (self._isInputComposing) { + return; + } switch (ev.which) { case $.ui.keyCode.ENTER: |
