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

semantic ui reagent problems #1

Closed
henryw374 opened this issue Jul 19, 2021 · 3 comments
Closed

semantic ui reagent problems #1

henryw374 opened this issue Jul 19, 2021 · 3 comments

Comments

@henryw374
Copy link

I appreciate this demo, but I think reagent is maybe not compatible with semantic-ui-react.

At first glance, the Input component appears to work, but after a key press the input box itself re-renders, causing the caret to move to the end. so for example if i enter 'aaaaa' and then place the caret somewhere in the middle of that and press b a few times, I get 'aabaaabbbb'. After the first b, the re-render causes the caret to lose position.

(defn input [] (reagent.core/with-let [state (reagent.core/atom "")] [:> ui/Input {:value @state :on-change (fn [_ v] (reset! state v.value))}]))

I would guess it is something to do with this https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/lib/ModernAutoControlledComponent.js, which is expecting you to use React's setState? In case you have a workaround I'd be interested to hear. thanks

@yogthos
Copy link
Owner

yogthos commented Jul 19, 2021

One workaround here could be to make the input uncontrolled and just set the initial value on focus, then reset the state atom on blur. This way the input won't repaint while the user is interacting with it.

@henryw374
Copy link
Author

Yep that could work! Where using a simple input one can also avoid the semantic ui input and just use the semantic ui styling.

Or probably even better... switch out Reagent or semantic-ui-react to get a better pairing.

@yogthos
Copy link
Owner

yogthos commented Jul 20, 2021

Yeah, I think whether using semantic-ui-react components directly or just the styling depends on the type of component. In a lot of cases components work fine, but edge cases like this necessitate a bit of creativity. :)

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

No branches or pull requests

2 participants