[BUG] <sp-textfield/> selects first character after `invalid` state changes

On first render I have empty <sp-textfield/>. I start typing and all seems fine. Then I delete text in the field, invalid state changes, input turns red. Then, when I start typing again, first character is lost, because it always gets selected after it’s typed

    const isFirstRender = useRef(true)
    const [error, setError] = useState(false)
    const [title, setTitle] = useState("")

    useEffect(() => {
        if (isFirstRender.current) {
            isFirstRender.current = false

            return
        }

        setError(!title)
    }, [title]);

    return (
        <sp-textfield
            invalid={error ? true : null}
            onInput={(e) => setTitle(e.target.value.trim())}
            value={title}
        >
            <sp-label isrequired={true} slot="label">Title</sp-label>
        </sp-textfield>
    )

No issue if there’s no invalid attribute at all or it never changes (can be true on first render)

3.5 years… Anything? I just got a client complaining about this issue :disappointed:

We’re looking forward to the next version of PS having a submenu: Plugins > Legacy2 > UXP… your plugins.

And the joyful news that: “Guys, we’re bringing back Chromium and Node.js, and xbytor is becoming the lead of the development team. We’ll come up with a name for the new platform later.” That would be awesome!

Does it happen in swc as well? Btw shouldn’t be label parent of textfield?

According to examples in the docs, no :confused:


Didn’t test now. At the time SWC was not available and now it would be lots of work to change everywhere :frowning:

I wouldn’t believe adobe uxp docs. Check mdn <label>: The Label element - HTML: HyperText Markup Language | MDN their example has label as parent.

I’ll need check that. But then there’s no point to have a slot at all and I guess it would misalign the UI from the default Ps UI recommendations. I want my plugin forms to look as close as possible to Ps UI and adapt if Adobe decides to make changes :frowning: