Fix incorrect usage of functional component (#17281)

Every keypress on an input field of the preview descriptor re-rendered the whole
functional component and the input focus was lost.

As we know from past issues, we should never use this pattern:

    (defn component
      []
      [:f>
       (fn []
         ...)])
This commit is contained in:
Icaro Motta 2023-09-13 13:22:53 -03:00 committed by GitHub
parent baa9dff237
commit dab4d953ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 37 deletions

View File

@ -229,15 +229,12 @@
style)}]
children)])
(defn preview-container
(defn- f-preview-container
[{:keys [state descriptor blur? blur-dark-only?
component-container-style
blur-container-style blur-view-props blur-height show-blur-background?]
:or {blur-height 200}}
& children]
[:f>
(fn []
(rn/use-effect (fn []
(when blur-dark-only?
(if blur?
@ -270,4 +267,8 @@
blur-view-props)}]
children)]
(into [rn/view {:style (merge style/component-container component-container-style)}]
children))]]])])
children))]]])
(defn preview-container
[& args]
(into [:f> f-preview-container] args))