Update manualy the input invalid property

This commit is contained in:
Arnaud 2025-03-31 20:41:09 +02:00
parent 579ab4fbed
commit 52c659b9f3
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
3 changed files with 10 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@codex-storage/marketplace-ui-components",
"version": "0.0.51",
"version": "0.0.52",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@codex-storage/marketplace-ui-components",
"version": "0.0.51",
"version": "0.0.52",
"license": "MIT",
"devDependencies": {
"@codex-storage/sdk-js": "https://github.com/codex-storage/codex-js#feat/support-basic-auth",

View File

@ -5,7 +5,7 @@
"type": "git",
"url": "https://github.com/codex-storage/codex-marketplace-ui-components"
},
"version": "0.0.51",
"version": "0.0.52",
"type": "module",
"scripts": {
"prepack": "npm run build",

View File

@ -3,6 +3,7 @@ import {
ComponentType,
forwardRef,
InputHTMLAttributes,
useEffect,
useState,
} from "react";
import { attributes } from "../utils/attributes";
@ -64,6 +65,12 @@ export const Input = forwardRef<HTMLInputElement, Props>(
) => {
const [invalid, setInvalid] = useState(isInvalid);
useEffect(() => {
if (mode === "manual") {
setInvalid(isInvalid);
}
}, [mode, isInvalid]);
const onInternalChange = (e: ChangeEvent<HTMLInputElement>) => {
if (mode === "auto") {
setInvalid(e.currentTarget.checkValidity() !== true);