[EuiSuperDatePicker] Allow passing canRoundRelativeUnits={false}, which turns off relative unit rounding#7502
Conversation
+ default it to true and pass it down to the subcomponents that will need it
+ add tests for `useFormatTimeString` - except for the roundUp option because I can't figure out what the heck that does 🤷
| onPopoverClose: EuiPopoverProps['closePopover']; | ||
| onPopoverToggle: MouseEventHandler<HTMLButtonElement>; | ||
| position: 'start' | 'end'; | ||
| preferLargerRelativeUnits?: boolean; |
There was a problem hiding this comment.
This prop name might be a bit unclear. What do you think of renaming it to relativeUnitRounding as in the title of this PR? :D I think including the word "rounding" makes it easier to search for when you see that rounding behavior and want to do something about it
There was a problem hiding this comment.
Yep, that does sound way better. Let's go with that!
There was a problem hiding this comment.
Actually, hm, does making it a verb sound better to you at all, out of curiosity? roundRelativeUnits={false} vs relativeUnitRounding={false}?
There was a problem hiding this comment.
Or yet another thought: if we want to follow is/has/can/shouldX naming convention style for booleans, we could do canRoundRelativeUnits, but now we're getting back into the original verbose var name territory lmao
There was a problem hiding this comment.
To recap our Slack discussion: We went with canRoundRelativeUnits for clearer boolean naming. roundRelativeUnits as a verb feels like it would take a callback rather than a boolean, so we avoided that (unless we someday want to do one of those union types that Tomasz hates so much, like Function | boolean 🤣)
Also our next datepicker component will definitely be named EuiSuperDuperDatePicker.
|
Great job on clean and quick implementation! The changes look and work great, I'll approve when you're happy with the naming of the new prop! |
e7a874e to
64b0fab
Compare
tkajtoch
left a comment
There was a problem hiding this comment.
approved.final.final.v7 (Copy).gif
preferLargerRelativeUnits={false}, which turns off relative unit roundingcanRoundRelativeUnits={false}, which turns off relative unit rounding
|
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
`v93.0.0` ⏩ `v93.1.1` --- ## [`v93.1.1`](https://github.com/elastic/eui/releases/v93.2.0) **This is a patch release primarily intended for use by Kibana.** - Added top-level `EuiTreeView.Item` export ([#7526](elastic/eui#7526)) ## [`v93.1.0`](https://github.com/elastic/eui/releases/v93.1.0) - Added `index` glyph to `EuiIcon` ([#7498](elastic/eui#7498)) - Updated `EuiHighlight` to accept an array of `search` strings, which allows highlighting multiple, separate words within its children. This new type and behavior *only* works if `highlightAll` is also set to true. ([#7496](elastic/eui#7496)) - Updated `EuiContextMenu` with a new `panels.items.renderItem` property, which allows rendering completely custom items next to standard `EuiContextMenuItem` objects ([#7510](elastic/eui#7510)) - `EuiSuperDatePicker` updates: - Updated `EuiSuperDatePicker` with a new `refreshIntervalUnits` prop. Passing this prop allows controlling and overriding the default unit rounding behavior. ([#7501](elastic/eui#7501)) - Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new `intervalUnits` prop. Passing this prop allows controlling and overriding the default unit rounding behavior. ([#7501](elastic/eui#7501)) - Updated `onRefreshChange` to pass back a new `intervalUnits` key that contains the current interval unit format (seconds, minutes, or hours). ([#7501](elastic/eui#7501)) - Updated `EuiSuperDatePicker` with a new `canRoundRelativeUnits` prop, which defaults to true (current behavior). To preserve displaying the unit that users select for relative time, set this to false. ([#7502](elastic/eui#7502)) - Updated `EuiSuperDatePicker` with a new `refreshMinInterval` prop, which accepts a minimum number in milliseconds ([#7516](elastic/eui#7516)) - Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new `minInterval` prop, which accepts a minimum number in milliseconds ([#7516](elastic/eui#7516)) **Bug fixes** - Fixed `EuiHighlight` to not parse `search` strings as regexes ([#7496](elastic/eui#7496)) - Fixed `EuiSuperDatePicker` submit bug when used within `<form>` elements ([#7504](elastic/eui#7504)) - Fixed an `EuiTreeView` bug where `aria-expanded` was being applied to items without expandable children ([#7513](elastic/eui#7513)) **CSS-in-JS conversions** - Converted `EuiTreeView` to Emotion. Updates as part of the conversion: ([#7513](elastic/eui#7513)) - Removed `.euiTreeView__wrapper` div node - Enforced consistent `icon` size based on `display` size
`v93.0.0` ⏩ `v93.1.1` --- ## [`v93.1.1`](https://github.com/elastic/eui/releases/v93.2.0) **This is a patch release primarily intended for use by Kibana.** - Added top-level `EuiTreeView.Item` export ([elastic#7526](elastic/eui#7526)) ## [`v93.1.0`](https://github.com/elastic/eui/releases/v93.1.0) - Added `index` glyph to `EuiIcon` ([elastic#7498](elastic/eui#7498)) - Updated `EuiHighlight` to accept an array of `search` strings, which allows highlighting multiple, separate words within its children. This new type and behavior *only* works if `highlightAll` is also set to true. ([elastic#7496](elastic/eui#7496)) - Updated `EuiContextMenu` with a new `panels.items.renderItem` property, which allows rendering completely custom items next to standard `EuiContextMenuItem` objects ([elastic#7510](elastic/eui#7510)) - `EuiSuperDatePicker` updates: - Updated `EuiSuperDatePicker` with a new `refreshIntervalUnits` prop. Passing this prop allows controlling and overriding the default unit rounding behavior. ([elastic#7501](elastic/eui#7501)) - Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new `intervalUnits` prop. Passing this prop allows controlling and overriding the default unit rounding behavior. ([elastic#7501](elastic/eui#7501)) - Updated `onRefreshChange` to pass back a new `intervalUnits` key that contains the current interval unit format (seconds, minutes, or hours). ([elastic#7501](elastic/eui#7501)) - Updated `EuiSuperDatePicker` with a new `canRoundRelativeUnits` prop, which defaults to true (current behavior). To preserve displaying the unit that users select for relative time, set this to false. ([elastic#7502](elastic/eui#7502)) - Updated `EuiSuperDatePicker` with a new `refreshMinInterval` prop, which accepts a minimum number in milliseconds ([elastic#7516](elastic/eui#7516)) - Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new `minInterval` prop, which accepts a minimum number in milliseconds ([elastic#7516](elastic/eui#7516)) **Bug fixes** - Fixed `EuiHighlight` to not parse `search` strings as regexes ([elastic#7496](elastic/eui#7496)) - Fixed `EuiSuperDatePicker` submit bug when used within `<form>` elements ([elastic#7504](elastic/eui#7504)) - Fixed an `EuiTreeView` bug where `aria-expanded` was being applied to items without expandable children ([elastic#7513](elastic/eui#7513)) **CSS-in-JS conversions** - Converted `EuiTreeView` to Emotion. Updates as part of the conversion: ([elastic#7513](elastic/eui#7513)) - Removed `.euiTreeView__wrapper` div node - Enforced consistent `icon` size based on `display` size
Summary
closes #4026, addresses elastic/kibana#143157
👋 I'm bad at naming things, please feel free to suggest a less wordy name for this prop if you can think of one!
💭 NOTE: If we find that users prefer this behavior as a default, we should potentially consider turning this flag on to default to
truein the future. This will require us to track usage and user feedback over time.Screencaps
QA
Playgroundlink on the pagecanRoundRelativeUnitscontrol and toggle it to false15to1500and confirm that the rendered output shows1500 minutes ago(instead of rounding up to a day)1500 hours ago(instead of rounding up to months etc)localeplayground toggle and change it to, e.g.frorjaGeneral checklist
@defaultif default values are missing) and playground toggles[ ] Added documentation- I don't consider this important enough to add an entire section for (vs. just testing in the playground), please LMK if you disagree!and cypress tests