react icon indicating copy to clipboard operation
react copied to clipboard

Reset button on iOS time input does not return correct event value

Open PingEleanor1 opened this issue 3 years ago • 7 comments

React version: React 17.0.2 IOS version: 14+

Bug

For iOS(Safari and Chrom). The reset button function does not work on the time input:

If I change time to 00:31, reset directly, the time jumps back to 00:30, but the computer still shows 00:31. When pressing reset on a time input, the onChange event is not fired.

reset

Link to code example: https://stackblitz.com/edit/react-enuflz?file=src%2FApp.js Pls try on iOS.

PingEleanor1 avatar Feb 15 '22 11:02 PingEleanor1

Hello @PingEleanor1,

thank you for the report. I was able to repro the issue and verified that there is an "change" event coming from browser when user presses "Reset."

sammy-SC avatar Feb 15 '22 15:02 sammy-SC

Seems like it's related to https://github.com/facebook/react/issues/8938

mmarkelov avatar Feb 20 '22 19:02 mmarkelov

Is this issue still open? I'm interested in working on it and would love to contribute.

shriphad-rao avatar Feb 25 '24 15:02 shriphad-rao

Yes, this issue is still open, and it is affecting some of my code right now. React v17.0.2, iPhone XR, iOS 16.6

BikramjeetSingh avatar Mar 01 '24 07:03 BikramjeetSingh

@shriphad-rao Have you found any solution?

BartoszDadok avatar Mar 16 '24 15:03 BartoszDadok

Workaround

const dateRef = useRef()

function handleDate(event) {
    const target = event.target;
    setTimeout(() => {
      target.defaultValue = "";
    }, 100);
}

<input ref={dateRef}  onChange={handleDate} value={state}/>```

alexandremacedo avatar Aug 19 '24 01:08 alexandremacedo

Workaround

const dateRef = useRef()

function handleDate(event) {
    const target = event.target;

    setTimeout(() => {
      target.defaultValue = "";
    }, 100);
}

<input ref={dateRef} onChange={handleDate} value={state}/>

What is the ref needed for in this example? It seems like it was set but never used. Kinda like a mix from the examples provided in #8938

Really don't understand why this issue is open for so long already and still not fixed.

nikischin avatar Aug 19 '24 06:08 nikischin