@dloizides/auth-web 1.18.2 → 1.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.18.3
4
+
5
+ - `useLoginSubmit` has an in-flight ref guard, like `useRegisterForm`. A focused field stays read-only (not
6
+ disabled) during a pending login and RN-web still fires `onSubmitEditing` there, so a second Enter sent a
7
+ second `/bff/login`. jsdom tests now cover a pending submit + a second non-repeat Enter for both forms,
8
+ a valid register submitted by Enter, and an IME-composition Enter not submitting.
9
+
3
10
  ## 1.18.2
4
11
 
5
12
  **Enter in a text field submits `<RegisterForm>` and `<LoginForm>`.**
package/dist/index.js CHANGED
@@ -618,7 +618,11 @@ function useLoginSubmit({
618
618
  invalidCredentialsLabel
619
619
  }) {
620
620
  const [errorText, setErrorText] = react.useState(null);
621
+ const inFlight = react.useRef(false);
621
622
  const runLogin = react.useCallback(async () => {
623
+ if (inFlight.current) {
624
+ return;
625
+ }
622
626
  setErrorText(null);
623
627
  const trimmedUsername = username.trim();
624
628
  const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
@@ -626,11 +630,14 @@ function useLoginSubmit({
626
630
  setErrorText(missingFieldsLabel);
627
631
  return;
628
632
  }
633
+ inFlight.current = true;
629
634
  try {
630
635
  const user = await login({ username: trimmedUsername, password });
631
636
  onSuccess(user);
632
637
  } catch {
633
638
  setErrorText(invalidCredentialsLabel);
639
+ } finally {
640
+ inFlight.current = false;
634
641
  }
635
642
  }, [username, password, login, onSuccess, missingFieldsLabel, invalidCredentialsLabel]);
636
643
  const handleSubmit = react.useCallback(() => {