-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workaround] Use uncontrolled inputs
Reagent's built-in workaround for controlled inputs doesn't work when we use the new `react.dom.client` API to render to a shadow root. This makes the cursor skip to the end whenever you try to insert a character into a text input field. This article describes the bug in some detail: https://github.com/reagent-project/reagent/blob/master/doc/ControlledInputs.md It also offers a workaround. Basically, for our :input components, instead of the :value prop (a controlled input), we use :default-value (uncontrolled). Then, we have to force the :input component to remount when we dispatch an event which would update the :default-value. That allows us to "control" the value via a subscription, while keeping the healthy cursor behavior of an "uncontrolled" input. So far, the only input we actually need to control is the new app-db editor. This is not a good smell, and could be a pitfall for future development. I think it's tolerable for now, though. I hope reagent can fix this issue - it seems really complicated. reagent-project/reagent#597
- Loading branch information
Showing
4 changed files
with
160 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters