react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

DatePicker focus and blur events are not being triggered

Open pavithra-ramaswamy opened this issue 2 years ago โ€ข 2 comments

๐Ÿ› Bug Report

Tried to invoke a few event based functions except for onChange the rest are not being invoked.

For example the on focus and blur functions: let elemAttrs = { onFocusChange:(e) => this.onFocusChange(e), onFocus:(e) => this.onFocus(e), onBlur:(e) => this.onBlur(e) };

๐Ÿค” Expected Behavior

Focus and blur related event handlers should be triggered

image

๐Ÿ˜ฏ Current Behavior

onBlur, onFocus, onFocusChange are not being triggered correctly

๐Ÿ’ Possible Solution

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample

const onFocusChange =() => { console.log("onFocusChange called"); }

const onFocus =() => { console.log("onFocus called"); }

const onBlur =() => { console.log("onBlur called"); }

let elemAttrs = { ...., onFocusChange:(e) => this.onFocusChange(e), onFocus:(e) => this.onFocus(e), onBlur:(e) => this.onBlur(e) };

<DatePicker {...elemAttrs} />

๐ŸŒ Your Environment

Software Version(s)
react-spectrum 3.19.0
Browser Chrome
Operating System MacOS

๐Ÿงข Your Company/Team

๐Ÿ•ท Tracking Issue (optional)

pavithra-ramaswamy avatar Jun 28 '22 19:06 pavithra-ramaswamy

reproduced here: https://codesandbox.io/s/elegant-dew-0xitgj?file=/src/App.js

snowystinger avatar Jun 29 '22 17:06 snowystinger

I am also facing same problem of onBlur not getting invoked. Any ETA on fix?

makarandkeer avatar Jul 21 '22 16:07 makarandkeer

We are facing the same problem using the useTimeField hook. onBlur is not being called.

joshuajaco avatar Oct 11 '22 12:10 joshuajaco

@joshuajaco thanks for the info. The draft pr linked to should fix this for the react-aria date hooks and the React Spectrum date components.

ktabors avatar Oct 11 '22 16:10 ktabors