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

Backspace can not erase the last one character during Japanese IME conversion (macOS) #9173

Closed
Thomas101 opened this issue Apr 12, 2017 · 19 comments

Comments

@Thomas101
Copy link
Contributor

  • Electron version: 1.6.2, 1.6.6, not 1.4.16
  • Operating system: macOS 10.12.2 Sierra, macOS 10.12.4

Expected behavior

When inputting Japanese sentences using the Japanese IME (Input Method Editor) to convert alphabets to Japanese (CJK) characters you should be able to delete each character in turn by pressing backspace

Actual behavior

The very last character always needs two backspace presses

How to reproduce

  • Clone my version of electron starter
$ git clone https://github.com/wavebox/electron-quick-start -b japanese_delete_bug
$ npm install
$ npm start
  • Go to System preferences > Language & Region
  • Press the + to add a language and add Japanese (about a whole scroll down for me)
  • When prompted use your current language as the primary language
  • Launch the repository clone of quickstart (above)
  • Using the flag icon in the mac top bar change your current input method to Katakana
  • Click in the input field, type a few characters, then start hitting backspace
  • To delete the last character you have to hit backspace twice

Some other things about this I've found...

  • Remove the webview tag from the page and it works as expected (input field is not within the webview, but does also affect it there)
  • Issue is reproducible in 1.6.2 & 1.6.6 (maybe others inbetween)
  • Issue not apparent in 1.4.16
  • Some gifs of the behaviour in the original issue
@kevinsawicki
Copy link
Contributor

I reported a related issue upstream where when the input is inside the <webview> tag, two backspaces are required to delete the last character, https://bugs.chromium.org/p/chromium/issues/detail?id=714771

@kevinsawicki
Copy link
Contributor

This will be fixed in the next Electron release, 1.7.2

@Thomas101
Copy link
Contributor Author

Awesome thank you :)

@kevinsawicki
Copy link
Contributor

Reopening this since the original fix introduced #9709 on 1.7.x.

Will revisit in 1.8.x since we can land further patches from upstream Chrome that have been applied since this original fix.

@achimnol
Copy link

This seems to be affecting the current releases of Slack, Microsoft Teams, and some other Electron-based apps. Subscribing this issue with hopes to be fixed soon!

@gerges-zz
Copy link

I'm having a hard time understanding the status of this issue. As far as i can tell this is fixed in 1.6.x, broken in 1.7.x, and ideally will be fixed again in 1.8.x? Is that correct?

@chenerzhang
Copy link

any update?

@chenerzhang
Copy link

You can test this way. My trouble is Chinese IME and this can help me solve this problem on mac.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Hello World!</title>
  <style>
    *,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html,
    body {
      width: 100%;
      height: 100%;
    }

    body {
      display: flex;
      flex-direction: column;
    }

    webview {
      flex: 1;
      width: 100%;
    }

    input {
      height: 300px;
    }
  </style>
</head>

<body>
  <textarea rows="10" id="input"></textarea>
  <webview src="https://www.google.com"></webview>
  <script>
    // You can also require other files to run in this process
    require('./renderer.js');
    const { exec, spawn } = require('child_process');

    const $input = document.querySelector('#input');
    let inputTimeStamp = 0;
    let inputNums = 0;
    let delta = 1;
    let backspaceKeydownTimestamp = 0;
    $input.addEventListener('input', (e) => {
      inputTimeStamp = e.timeStamp;
      inputNums += delta;
    });
    $input.addEventListener('keyup', (e) => {
      if (e.key === 'Backspace') {
        let deleteFlag = false;
        // slow delete detect
        if (inputTimeStamp === -1) {
          deleteFlag = true;
          delta = 1;
          inputTimeStamp = 0;
          exexDelete();
        }
        // quick delete detect
        if (!deleteFlag && inputNums === 1 && e.timeStamp - backspaceKeydownTimestamp < 60) {
          inputNums = 0;
          exexDelete();
        }
      }
      inputTimeStamp = -1;
    });
    $input.addEventListener('keydown', (e) => {
      if (e.key === 'Backspace') {
        backspaceKeydownTimestamp = e.timeStamp;
        delta = -1;
      } else {
        delta = 1;
      }
    });
    $input.addEventListener('compositionstart', () => {
      inputTimeStamp = 0;
      inputNums = 0;
      delta = 1;
      backspaceKeydownTimestamp = 0;
    });
    function exexDelete() {
      const ps = spawn('osascript');
      ps.stdin.write(`
      tell application "System Events"
        keystroke ascii character 8
      end tell
      `);
      ps.stdin.end();
    }
  </script>
</body>

</html>

@zjfjiayou
Copy link

I have encountered the same problem in this version 1.7.11. The language is Chinese.

@aceimnorstuvwxz
Copy link

same problem on 1.7.10, Chinese

@kenan2002
Copy link

I'm in trouble with this issue, too.
I see that this issue has been fixed in Electron 2.0 beta which is based on Chromium 61. Is there any plan on an Electron 1.x version based on Chromium 61 or above so that we can fix this issue without any impact of breaking-changed API?

@zoubingwu
Copy link

Yes, we really need this to be fixed, pls make it happen in 1.8.x if possible, plsssssssssss
🙇

@codebytere
Copy link
Member

We are no longer implementing bugfixes for versions of Electron <= 1.7.x, so i'm going to close this issue but if it is still persisting in more recent versions of Electron we can certainly reopen it!

@tete1030
Copy link

tete1030 commented Dec 3, 2018

We are no longer implementing bugfixes for versions of Electron <= 1.7.x, so i'm going to close this issue but if it is still persisting in more recent versions of Electron we can certainly reopen it!

The version 2.0.12 is still broken on this issue after it was fixed in 2.0 beta. VSCode's latest version 1.29.1 is using Electron 2.0.12. Please see:
microsoft/vscode#37114 (comment)

I'm using macOS 10.14.1

@nornagon nornagon added the 2-0-x label Dec 3, 2018
@nornagon
Copy link
Member

nornagon commented Dec 3, 2018

Is there any chance you could verify this on 3.0.x or 4.0.x-beta? Perhaps with Electron Fiddle?

@nornagon nornagon reopened this Dec 3, 2018
@tete1030
Copy link

tete1030 commented Dec 4, 2018

Sorry, while I can reproduce this issue in v1.8.8, I cannot reproduce it in 2.0.7, 2.0.12, 3.0.10, 4.0.0-beta.8 .
I tested them with Electron Fiddle with the following code using macOS Pinyin input method.

<webview src="data:text/html,<input type=text />"></webview>

I'm also reporting this result to the vscode issue.

@rebornix
Copy link

rebornix commented Dec 4, 2018

@tete1030 input in webview is not no longer affected while input outside of webview is still running into this issue.

Sample html to reproduce

<input />
<webview src="data:text/html,<input type=text />"></webview>

The issue is gone in 3.0.10 and 4.0.0-beta.8 but IMO we should have a fix for 2.x

@tete1030
Copy link

tete1030 commented Dec 5, 2018

The fix is between 3.0.0-beta.5 and 3.0.0-beta.6

@sofianguy
Copy link
Contributor

Given this is reported as fixed in 4.x, I will close this issue. We are no longer supporting versions earlier than 4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests