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

scrollWidth error in DatePicker

Open melcherry98 opened this issue 1 year ago โ€ข 2 comments

๐Ÿ› Bug Report

I get an error when I use the DatePicker V3 and a TagField V2 inside of the Dialog after closing the dialog:

๐Ÿค” Expected Behavior

I shouldn't see an error.

๐Ÿ˜ฏ Current Behavior

I get the error below when I use the DatePicker V3 and a TagField V2 inside of the Dialog after closing the dialog:

Screen Shot 2022-07-28 at 10 08 31 AM

Reproduction Steps

  • Have this kind of structure:
<Dialog>
<TagField>
<DatePicker>
</Dialog>
  • Use the DatePicker
  • Use the TagField
  • Submit

https://user-images.githubusercontent.com/29243259/181639672-ff003d07-81ef-40cd-afa5-0d04b2af6f3e.mov

๐Ÿ’ Possible Solution

Add a null check on this line: https://github.com/adobe/react-spectrum/blob/main/packages/@react-spectrum/datepicker/src/Input.tsx#L42

๐Ÿ”ฆ Context

This bug is blocking the release of a new feature.

๐Ÿ’ป Code Sample

This code sandbox does not reproduce the error, but does give some context. code sandbox

The "Recipients" field is a V2 TagField component in the actual implementation.

๐ŸŒ Your Environment

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

๐Ÿงข Your Company/Team

Adobe/Marketo Engage

๐Ÿ•ท Tracking Issue (optional)

melcherry98 avatar Jul 28 '22 21:07 melcherry98

Strange that the codesandbox doesn't reproduce the issue, but adding a null check to the line you linked makes sense. Just a fyi: I've removed the JIRA link since we don't wanna expose internal Adobe links in these issues, we should probably get rid of that section from the issue template haha.

LFDanLu avatar Jul 29 '22 18:07 LFDanLu

@melcherry98 Since we aren't able to reproduce it via a codesandbox, would you mind trying to apply your suggested fix locally just to double check that it resolves the issue? You can do so via patch package or modifying your node_modules locally

LFDanLu avatar Aug 03 '22 21:08 LFDanLu

Sorry it took so long to circle back. Yes, changing that line to if (inputRef && inputRef.current && inputRef.current.scrollWidth > inputRef.current.offsetWidth) { does resolve our issue. Thank you for your help!

melcherry98 avatar Aug 18 '22 18:08 melcherry98