Giter Site home page Giter Site logo

Comments (5)

WhoAteDaCake avatar WhoAteDaCake commented on May 1, 2024

Hi, I've begun working on this, however, as I am relatively new to ocaml/reason ecosystem, I am not sure how to implement the focus module. So far I have, but that would cause a dependency cycle.

module Make = (T: {type t;}) => {
  let focusedNode: ref(option(Node.node(T.t))) = ref(None);

  let focusOn = (node: Node.node(T.t)) => {
    let _ =
      switch (focusedNode^) {
      | None => ()
      | Some(node) => node#blur()
      };
    focusedNode := Some(node);
  };
};

from revery.

WhoAteDaCake avatar WhoAteDaCake commented on May 1, 2024

Would I have to implement a focusable sub-class, make sure node extends it and the use that for type parameters?

from revery.

bryphe avatar bryphe commented on May 1, 2024

Thanks a lot for taking this on, @WhoAteDaCake !

That functor looks like a solid start - it looks like it'd be testable. Based on the dependency issue - I'm thinking it'd be nice if the Node didn't need to know about focus management. It could work the following way:

  • The focus module keeps track of the active node
  • Input events get funneled through the Focus module (we could implement a Focus.dispatch - like what we did for Mouse events here:
    let dispatch =
    - that logic finds the element under the cursor, and dispatches a mouse event (bubbling it up) - the focus module would want to do similiar bubbling, but the logic could actually be simpler than the mouse case - it would dispatch against the currently active node, if there is one).
  • We could add Blur and Focus events to NodeEvents
  • Instead of sending a Node object to the ref - we could send a more functional wrapper. This would contain a blur and focus method, which, under the hood, would call to the Focus module. This 'proxying' could be facilitated by wrapping the onRef in NodeEvents

This would decouple the dependency tree - because the node wouldn't need to care about focus management, the only concern the Node would have with regard to focus is respond to Blur and Focus events, and dispatching to the appropriate handler in NodeEvents.

Still a little vague, but hopefully that helps give some ideas. Thanks for thinking about this!

from revery.

WhoAteDaCake avatar WhoAteDaCake commented on May 1, 2024

I've open #199 . That implements the basic functionality required for focus management.

from revery.

saitonakamura avatar saitonakamura commented on May 1, 2024

Maybe we can update this issue to indicate what's already done and what's missing?
Also, @bryphe , in Testability section first case should be most likely without tabindex instead of with

from revery.

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.