Theia: widgets input can't undo

Created on 25 Sep 2019  路  6Comments  路  Source: eclipse-theia/theia

Description

temp

Reproduction Steps

  • input some thing in main editor
  • Ctrl + F open search at editor
  • input some thing in search widgets
  • Ctrl + Z undo input
  • search widgets nothing happend but main editor undo it

OS and Theia version:
Diagnostics:

bug editor

Most helpful comment

@spoenemann @502647092 @Hanksha Could you reproduce it against https://github.com/eclipse-theia/theia/pull/7481? fyi I cannot

Please help with testing 馃檹 You can test with Gitpod: https://gitpod.io#https://github.com/eclipse-theia/theia/pull/7481

All 6 comments

Something wrong with registered keybindings, i.e. there should be undo handler for the search widget registered from Monaco which takes priority over default handler by when closure.

The same problem applies to all other input fields: Search view (search text), Git view (commit message) etc.

I just encountered that as well, I can't use undo/redo in any input text or textarea I used.
The fix for me was to add this:

const isTextElementFocused = () => {
    const activeElement = document.activeElement;
    return (activeElement instanceof HTMLInputElement && activeElement.type === "text") ||
        activeElement instanceof HTMLTextAreaElement;
};
commands.registerHandler(CommonCommands.UNDO.id, {
    execute: () => {
        document.execCommand("undo", true);
    },
    isEnabled: isTextElementFocused
});
commands.registerHandler(CommonCommands.REDO.id, {
    execute: () => {
        document.execCommand("redo", true);
    },
    isEnabled: isTextElementFocused
});

Although the documentation says document.execCommand might not work for every browser. Works well so far (tested on chrome and safari).

@spoenemann @502647092 @Hanksha Could you reproduce it against https://github.com/eclipse-theia/theia/pull/7481? fyi I cannot

Please help with testing 馃檹 You can test with Gitpod: https://gitpod.io#https://github.com/eclipse-theia/theia/pull/7481

Yes it seems the issue is fixed in that revision!

Looks like it's fixed, I'll try within my project as well once it's merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeanlucburot picture jeanlucburot  路  3Comments

vinokurig picture vinokurig  路  3Comments

pwFoo picture pwFoo  路  3Comments

akosyakov picture akosyakov  路  3Comments

akosyakov picture akosyakov  路  3Comments