fix inability to move cursor to next line in bio field (#20403)

This commit is contained in:
Parvesh Monu 2024-06-13 13:56:33 +05:30 committed by GitHub
parent 874906b11f
commit df939bf85f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 60 additions and 61 deletions

View File

@ -4,7 +4,6 @@
[react-native.core :as rn]
[react-native.platform :as platform]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.common.validation.profile :as profile-validator]
[status-im.constants :as constants]
[status-im.contexts.profile.edit.bio.style :as style]
@ -18,20 +17,19 @@
profile (rf/sub [:profile/profile-with-image])
customization-color (rf/sub [:profile/customization-color])
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
profile-bio (:bio profile)
unsaved-bio (reagent/atom profile-bio)
error-msg (reagent/atom nil)
typing? (reagent/atom false)
current-bio (:bio profile)
[bio set-bio] (rn/use-state current-bio)
[error-msg set-error-msg] (rn/use-state nil)
[typing? set-typing] (rn/use-state false)
validate-bio (debounce/debounce (fn [bio]
(reset! error-msg
(profile-validator/validation-bio bio))
(reset! typing? false))
(set-error-msg (profile-validator/validation-bio
bio))
(set-typing false))
300)
on-change-text (fn [s]
(reset! typing? true)
(reset! unsaved-bio s)
(set-typing true)
(set-bio s)
(validate-bio s))]
(fn []
[quo/overlay
{:type :shell
:container-style (style/page-wrapper insets)}
@ -49,28 +47,29 @@
[quo/input
{:blur? true
:multiline? true
:error? (not (string/blank? @error-msg))
:error? (not (string/blank? error-msg))
:container-style {:margin-bottom -11}
:default-value @unsaved-bio
:default-value bio
:auto-focus true
:max-height 200
:char-limit constants/profile-bio-max-length
:label (i18n/label :t/profile-bio)
:placeholder (i18n/label :t/something-about-you)
:on-change-text on-change-text}]
(when-not (string/blank? @error-msg)
(when-not (string/blank? error-msg)
[quo/info-message
{:type :error
:size :default
:icon :i/info}
@error-msg])]
error-msg])]
[rn/view {:style style/button-wrapper}
[quo/button
{:type :primary
:customization-color customization-color
:on-press (fn []
(rf/dispatch [:profile/edit-bio @unsaved-bio]))
:disabled? (boolean (or @typing?
(and (string/blank? profile-bio)
(string/blank? @unsaved-bio))
(not (string/blank? @error-msg))))}
(i18n/label :t/save-bio)]]]])))
(rf/dispatch [:profile/edit-bio bio]))
:disabled? (boolean (or typing?
(and (string/blank? current-bio)
(string/blank? bio))
(not (string/blank? error-msg))))}
(i18n/label :t/save-bio)]]]]))