Skip to content

Commit aa3482e

Browse files
authored
Bug/passwords do not match validation error does not appear until first password field is focused #22449 (#22455)
1 parent cefc3ec commit aa3482e

File tree

1 file changed

+16
-31
lines changed
  • src/status_im/contexts/onboarding/create_password

1 file changed

+16
-31
lines changed

src/status_im/contexts/onboarding/create_password/view.cljs

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,18 @@
2828

2929
(defn password-inputs
3030
[{:keys [set-password set-repeat-password same-password-length? same-passwords?
31-
password-long-enough? password-short-enough? non-empty-password?]}]
32-
(let [[show-validation?
33-
set-show-validation?] (rn/use-state false)
34-
on-change-password (rn/use-callback
35-
(fn [new-value]
36-
(set-password new-value)
37-
(when same-password-length?
38-
(set-show-validation? true)))
39-
[same-password-length?])
40-
on-change-repeat-password (rn/use-callback
41-
(fn [new-value]
42-
(set-repeat-password new-value)
43-
(when same-password-length?
44-
(set-show-validation? true)))
45-
[same-password-length?])
46-
on-blur-repeat-password (rn/use-callback
47-
#(set-show-validation? non-empty-password?)
48-
[non-empty-password?])
49-
hint-1-status (if password-long-enough? :success :default)
50-
hint-2-status (if same-passwords? :success :error)
51-
hint-2-text (if same-passwords?
52-
(i18n/label :t/password-creation-match)
53-
(i18n/label :t/password-creation-dont-match))
54-
error? (and show-validation?
55-
(not same-passwords?)
56-
non-empty-password?)]
31+
password-long-enough? password-short-enough?]}]
32+
(let [hint-1-status (if password-long-enough? :success :default)
33+
hint-2-status (if same-passwords? :success :error)
34+
hint-2-text (if same-passwords?
35+
(i18n/label :t/password-creation-match)
36+
(i18n/label :t/password-creation-dont-match))
37+
[error? set-error] (rn/use-state false)]
38+
(rn/use-effect
39+
(fn []
40+
(when (and (not error?) same-password-length? (not same-passwords?))
41+
(set-error true)))
42+
[error? same-password-length? same-passwords?])
5743
[:<>
5844
[password-with-hint/view
5945
{:hint (if (not password-short-enough?)
@@ -64,17 +50,16 @@
6450
:status hint-1-status
6551
:shown? true})
6652
:placeholder (i18n/label :t/password-creation-placeholder-1)
67-
:on-change-text on-change-password
53+
:on-change-text set-password
6854
:auto-focus true}]
6955
[rn/view {:style style/space-between-inputs}]
7056
[password-with-hint/view
7157
{:hint {:text hint-2-text
7258
:status hint-2-status
73-
:shown? (and non-empty-password? show-validation?)}
74-
:error? error?
59+
:shown? (or same-passwords? error?)}
60+
:error? (and error? (not same-passwords?))
7561
:placeholder (i18n/label :t/password-creation-placeholder-2)
76-
:on-change-text on-change-repeat-password
77-
:on-blur on-blur-repeat-password}]]))
62+
:on-change-text set-repeat-password}]]))
7863

7964
(defn help
8065
[{:keys [lower-case? upper-case? numbers? symbols?] :as validations}]

0 commit comments

Comments
 (0)