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

(WIP) Removing date segment placeholder default width

Open ktabors opened this issue 1 year ago โ€ข 6 comments

Full width is no longer reserved for date segments in DateField, TimeField, DatePicker, and DateRangePicker. Segments take the space of the placeholder or their value.

This also resolves #6183

Field sizes might adjust because the placeholder is no longer italic which makes it a few pixels smaller. This will break a lot of Chromatic stories.

There are some existing component fields that already shrink/grow when you edit the segments. It's only with some components, in some cases. This can be caused by:

  • changing the AM/PM
  • switching to a year that uses GMT+X instead of a time zone.
  • switching the month so the time zone changes.

๐Ÿงข Your Project:

RSP

ktabors avatar Jun 18 '24 05:06 ktabors

One other problem appears to be that when you type into the field, the entire field gets wider or shorter...

devongovett avatar Jun 18 '24 22:06 devongovett

I also found that Android now crashes when trying to change AM/PM in the time field. Steps to reproduce:

I was able to reproduce it on an another PR build. Follow the same steps, but when it doesn't crash press backspace and then it crashes. We should enter a bug for this.

ktabors avatar Jul 12 '24 23:07 ktabors

## API Changes

unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any', access: 'private' } unknown top level export { type: 'any', access: 'private' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'identifier', name: 'Column' } unknown top level export { type: 'identifier', name: 'Column' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' }

@react-stately/datepicker

DateFieldState

 DateFieldState {
   calendar: Calendar
   clearSegment: (SegmentType) => void
   confirmPlaceholder: () => void
   dateFormatter: DateFormatter
   dateValue: Date
   decrement: (SegmentType) => void
   decrementPage: (SegmentType) => void
   formatValue: (FieldOptions) => string
+  getDateFormatter: (string, FormatterOptions) => DateFormatter
   granularity: Granularity
   increment: (SegmentType) => void
   incrementPage: (SegmentType) => void
   isDisabled: boolean
   isReadOnly: boolean
   isRequired: boolean
   maxGranularity: 'year' | 'month' | Granularity
   segments: Array<DateSegment>
   setSegment: (SegmentType, number) => void
   setValue: (DateValue) => void
   value: DateValue
 }
 

it changed:

  • useDateFieldState

DatePickerState

 DatePickerState {
   dateValue: DateValue
   formatValue: (string, FieldOptions) => string
+  getDateFormatter: (string, FormatterOptions) => DateFormatter
   granularity: Granularity
   hasTime: boolean
   isInvalid: boolean
   isOpen: boolean
   setOpen: (boolean) => void
   setTimeValue: (TimeValue) => void
   setValue: (DateValue | null) => void
   timeValue: TimeValue
   value: DateValue | null
 }
 

it changed:

  • useDatePickerState

DateRangePickerState

 DateRangePickerState {
   dateRange: DateRange | null
   formatValue: (string, FieldOptions) => {
     start: string
   end: string
 }
+  getDateFormatter: (string, FormatterOptions) => DateFormatter
   granularity: Granularity
   hasTime: boolean
   isInvalid: boolean
   isOpen: boolean
   setDateRange: (DateRange) => void
   setDateTime: ('start' | 'end', DateValue) => void
   setOpen: (boolean) => void
   setTime: ('start' | 'end', TimeValue) => void
   setTimeRange: (TimeRange) => void
   setValue: (DateRange | null) => void
   timeRange: TimeRange | null
   value: DateRange | null
 }
 

it changed:

  • useDateRangePickerState

rspbot avatar Jul 15 '24 17:07 rspbot

filed https://github.com/orgs/adobe/projects/19/views/4?pane=issue&itemId=70985842 for the Android crash

Seems like this bug is basically https://github.com/adobe/react-spectrum/issues/6183 except that instead of crashing, it concatenates AM and PM (so that it looks like AMPM).

I followed the same steps to reproduce the crash above on main, and when it would crash here, it would concatenate AMPM.

yihuiliao avatar Jul 15 '24 18:07 yihuiliao