Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widgets input can't undo #6256

Closed
502647092 opened this issue Sep 25, 2019 · 6 comments
Closed

widgets input can't undo #6256

502647092 opened this issue Sep 25, 2019 · 6 comments
Assignees
Labels
bug bugs found in the application editor issues related to the editor

Comments

@502647092
Copy link
Contributor

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:

@akosyakov akosyakov added editor issues related to the editor bug bugs found in the application help wanted issues meant to be picked up, require help labels Sep 25, 2019
@akosyakov
Copy link
Member

akosyakov commented Sep 25, 2019

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.

@spoenemann
Copy link
Contributor

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

@Hanksha
Copy link
Contributor

Hanksha commented Mar 13, 2020

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).

@akosyakov
Copy link
Member

akosyakov commented Apr 6, 2020

@spoenemann @502647092 @Hanksha Could you reproduce it against #7481? fyi I cannot

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

@spoenemann
Copy link
Contributor

Yes it seems the issue is fixed in that revision!

@Hanksha
Copy link
Contributor

Hanksha commented Apr 6, 2020

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

@akosyakov akosyakov removed the help wanted issues meant to be picked up, require help label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application editor issues related to the editor
Projects
None yet
Development

No branches or pull requests

5 participants