Git Product home page Git Product logo

Comments (5)

devoncarew avatar devoncarew commented on May 4, 2024

@skybrian, is this something you could create a PR for?

from codemirror.dart.

skybrian avatar skybrian commented on May 4, 2024

Maybe, but I'm not sure about the consequences. I think a one line change at [1] to remove "sync: true" would fix this issue. However, I don't know if that would affect performance or timing in a bad way for other users of the CodeMirror package. Also, it looks like you added that line as part of a large change to upgrade to CodeMirror 5.0. Do you remember why you added it?

(It's not a big priority for me as I've already worked around it, but I thought I'd report it.)

[1] https://github.com/google/codemirror.dart/blob/master/lib/src/js_utils.dart#L70

from codemirror.dart.

devoncarew avatar devoncarew commented on May 4, 2024

Unfortunately I don't remember what motivated that change. I have in the past needed to make async user events sync in order to make sure I'm the one who handles the event (and can then cancel it), or because the browser only allows some actions when responding to a user event. Not sure if either was the case here.

from codemirror.dart.

skybrian avatar skybrian commented on May 4, 2024

A more conservative solution might be to set a flag when entering codemirror, and create a microtask in the callback if the flag is set. If the flag isn't set then the event was triggered from outside Dart and microtask is needed.

But since I've already worked around it, I think the easiest thing for now is just to leave the bug open.

from codemirror.dart.

skybrian avatar skybrian commented on May 4, 2024

More subtlety to think about: If some CodeMirror events are delivered via a microtask and others are not, they would get delivered out of order.

Also, in a regular HTML event handler, events are delivered synchronously, allowing you to call event.preventDefault(). I don't know if it's possible to handle an HTML event that is also delivered to CodeMirror, but if so, a microtask would change the order.

An interesting article about this:
https://plus.google.com/u/0/+MalteUbl/posts/NLyinvqwZHo

from codemirror.dart.

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.