Coder Social home page Coder Social logo

Comments (4)

lilactown avatar lilactown commented on September 21, 2024

The example above might be a bit contrived, as I could move the dynamic component to only contain the (ui/label counter).

However, in a project I have my own implementation of text-field that I've forked and modified to have "disabled" and "error" states, along with button and in the future more components. The approach I'm taking is to use context for these, e.g.

(def form
  (ui/dynamic
   ctx
   [disabled? (:disabled? @*form-state)]
   (disable disabled?
     (ui/column
      (text-field *form-state)
      (button on-submit (ui/label "Submit"))))))

This is very convenient, as I can group components together that should be disabled or have error borders & messages. However, because text-field now needs to be re-rendered by the dynamic parent with the new context, it loses its focus state.

from humbleui.

tonsky avatar tonsky commented on September 21, 2024

Yeah, that’s a known problem :( Dynamic basically re-creates entire subtree when its inputs change. New components lose parts of their state (even though everything about text-field is stored in atom, I guess I missed focus somehow). I plan to eventually replace dynamic with something more reliable, and also make sure that replacing components with similar ones doesn’t destroy any important state

from humbleui.

Quezion avatar Quezion commented on September 21, 2024

Tested on latest HumbleUI & can confirm this bug is still active. I was hoping some of the latest main commits about signals & vdom might've fixed it, but I suppose neither of those solve the component-state storage problem.

I'll continue using my crudely patched version from #71 for now. I'd be willing to help on this issue but I'm not sure of the next steps or vision for it.

from humbleui.

tonsky avatar tonsky commented on September 21, 2024

They could solve it, but the commits were just tests, not merged into main impl. I haven’t made a decision to go with them yet

from humbleui.

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.