Giter Club home page Giter Club logo

Comments (5)

PaddiM8 avatar PaddiM8 commented on June 14, 2024

Not sure why the circumflex would be deleted. I can't reproduce that on my machine. However, I now made sure a⋅⋅b gets parsed as a^b in the latest commit.

from kalker.

MonaMayrhofer avatar MonaMayrhofer commented on June 14, 2024

Thanks!

I think its because I'm on a german quertz keyboard and entering a circumflex would start to create a compose key input. Like the sequence ^ a results in â. If i actually want to type a circumflex, I would have to type ^ ^. The first circumflex to enter composing mode, and the second one to confirm the compose as "yes i would like a circumflex". The same thing is with keys like ` and ´

In the oninput event this behaviour seems to be handled with specifying the composed and isComposed properties in the event.

In total there are 4 oninput events that are triggered:

First: ^

  • {"isComposing":true,"composed":true,"inputType":"insertCompositionText","data":"^"}

Second: ^

  • {"isComposing":true,"composed":true,"inputType":"insertCompositionText","data":""}
  • {"isComposing":false,"composed":true,"inputType":"insertCompositionText","data":""}
  • {"isComposing":false,"composed":true,"inputType":"insertText","data":"^"}

Note that the circumflex immediately disappears after typing the first one - without any further interaction... So my guess would be that the whole composition cycle gets somehow cancelled and therefore deletes the "fake" circumflex that indicates that i am in the composing mode...

Here is some more info on that bizz.

from kalker.

MonaMayrhofer avatar MonaMayrhofer commented on June 14, 2024

I managed to reproduce these shenanigans:

<html>

<head>
  <script>
    function inp(e) {
      let b = document.getElementById("blub");

      e.target.selectionStart = e.target.selectionStart;
      e.target.selectionEnd = e.target.selectionStart;
    }
  </script>
</head>

<textarea id="blub" oninput="inp(event)"></textarea>

</html>

So i guess the problem is that when I enter the composing mode by entering the first circumflex, the selection of the textfield is immediately updated, which is interpreted by the browser as "the cursor moved so we need to cancel the composing"

If i wrap the changing of the selection in an if, then it works.

<html>

<head>
  <script>
    function inp(e) {
      let b = document.getElementById("blub");

      if (e.inputType !== "insertCompositionText") {
        e.target.selectionStart = e.target.selectionStart;
        e.target.selectionEnd = e.target.selectionStart;
      }
    }
  </script>
</head>

<textarea id="blub" oninput="inp(event)"></textarea>

</html>

Maybe inserting a similar if here solves the issue....

function handleInput(e: Event) {
if (ignoreNextInput) {
ignoreNextInput = false;
return;
}
const event = e as InputEvent;
const target = event.target as HTMLInputElement;
setText(target.value == "\n" ? "" : target.value);
if (event.data == "(") {
insertText(")");
offsetCaret(-1);
}
}

But I am not at all aware of any side effects this may have, and I know nearly nothing about this whole key composing stuff myself, so take all of this with a grain of salt, should you or someone else decide to look into this rabbithole.

from kalker.

MonaMayrhofer avatar MonaMayrhofer commented on June 14, 2024

This would be a very quick fix for it, that seems to work reasonably well: MonaMayrhofer@77bd037. Normally the circumflex would be somehow highlighted as being "fake", (normally underlined), but that would not be as straight forward to implement.

Well that's it for me for now, I don't know how many users are actually affected by this (i personally thought this was standard behavior but as you cannot reproduce it, it does not seem to be as standard).

from kalker.

PaddiM8 avatar PaddiM8 commented on June 14, 2024

@MonaMayrhofer That looks like a reasonable fix and doesn't seem to cause any issues, neat. Feel free to make a pull request!

from kalker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.