@povio/ui 2.2.9-rc.33 → 2.2.9-rc.34

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.
@@ -1,20 +1,24 @@
1
- import { useEffect, useRef, useState } from "react";
1
+ import { useLayoutEffect, useRef, useState } from "react";
2
2
  //#region src/components/inputs/shared/useStaticInputHandoff.ts
3
3
  var useStaticInputHandoff = ({ inputRef, renderInput, setRenderInput, getFocusTarget }) => {
4
4
  const [shouldFocus, setShouldFocus] = useState(false);
5
5
  const pendingStaticChangeRef = useRef(null);
6
- useEffect(() => {
6
+ useLayoutEffect(() => {
7
7
  if (!renderInput || !shouldFocus) return;
8
- const frame = requestAnimationFrame(() => {
8
+ const focusRealInput = (replayPendingChange) => {
9
9
  const input = inputRef.current;
10
10
  const pendingValue = pendingStaticChangeRef.current;
11
11
  const focusTarget = input ? getFocusTarget?.(input) ?? input : null;
12
- if (focusTarget instanceof HTMLInputElement && pendingValue != null) {
12
+ if (replayPendingChange && focusTarget instanceof HTMLInputElement && pendingValue != null) {
13
13
  (Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set)?.call(focusTarget, pendingValue);
14
14
  focusTarget.dispatchEvent(new Event("input", { bubbles: true }));
15
15
  pendingStaticChangeRef.current = null;
16
16
  }
17
17
  focusTarget?.focus();
18
+ };
19
+ focusRealInput(true);
20
+ const frame = requestAnimationFrame(() => {
21
+ focusRealInput(false);
18
22
  setShouldFocus(false);
19
23
  });
20
24
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.33",
3
+ "version": "2.2.9-rc.34",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",