feat(RelativeRangeDatePicker): allow null values in relative range presets#188
Open
feat(RelativeRangeDatePicker): allow null values in relative range presets#188
Conversation
Contributor
|
Preview is ready. |
ValeraS
requested changes
May 19, 2025
src/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.tsx
Outdated
Show resolved
Hide resolved
src/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.tsx
Outdated
Show resolved
Hide resolved
src/components/RelativeRangeDatePicker/__stories__/RelativeRangeDatePiker.stories.tsx
Outdated
Show resolved
Hide resolved
ValeraS
requested changes
Jun 9, 2025
Comment on lines
91
to
93
| allowNullableValues: true, | ||
| withPresets: true, | ||
| presetTabs: DEFAULT_RANGE_DATE_PICKER_PRESET, |
Collaborator
There was a problem hiding this comment.
Why are you trying to mess with arguments of the default story? If you want to show example with custom presets, you can do it via argTypes or another story.
| itemHeight={SIZE_TO_ITEM_HEIGHT[size]} | ||
| onItemClick={(item) => { | ||
| onChoosePreset(item.from, item.to); | ||
| onChoosePreset(item?.from, item?.to); |
Collaborator
There was a problem hiding this comment.
Why do you need optional chaining here?
Comment on lines
48
to
53
| if (!start) { | ||
| return `${i18n('To')}: ${endText}`; | ||
| } | ||
| if (!end) { | ||
| return `${i18n('From')}: ${startText}`; | ||
| } |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (!start) { | |
| return `${i18n('To')}: ${endText}`; | |
| } | |
| if (!end) { | |
| return `${i18n('From')}: ${startText}`; | |
| } | |
| if (!startText) { | |
| return `${i18n('To')}: ${endText}`; | |
| } | |
| if (!endText) { | |
| return `${i18n('From')}: ${startText}`; | |
| } |
Comment on lines
55
to
56
| if (end === 'now') { | ||
| const match = lastRe.exec(startText); | ||
| const match = lastRe.exec(startText || ''); |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (end === 'now') { | |
| const match = lastRe.exec(startText); | |
| const match = lastRe.exec(startText || ''); | |
| if (endText === 'now') { | |
| const match = lastRe.exec(startText); |
Comment on lines
47
to
59
| let start, end; | ||
| if (value.start === null) { | ||
| start = null; | ||
| } | ||
| if (value.start?.type === 'relative') { | ||
| start = value.start?.value || ''; | ||
| } | ||
| if (value.end === null) { | ||
| end = null; | ||
| } | ||
| if (value.end?.type === 'relative') { | ||
| end = value.end?.value || ''; | ||
| } |
Collaborator
There was a problem hiding this comment.
Suggested change
| let start, end; | |
| if (value.start === null) { | |
| start = null; | |
| } | |
| if (value.start?.type === 'relative') { | |
| start = value.start?.value || ''; | |
| } | |
| if (value.end === null) { | |
| end = null; | |
| } | |
| if (value.end?.type === 'relative') { | |
| end = value.end?.value || ''; | |
| } | |
| let start = null; | |
| let end = null; | |
| if (value.start?.type === 'relative') { | |
| start = value.start.value; | |
| } | |
| if (value.end?.type === 'relative') { | |
| end = value.end.value; | |
| } |
Comment on lines
36
to
37
| start?: string | null, | ||
| end?: string | null, |
Collaborator
There was a problem hiding this comment.
Suggested change
| start?: string | null, | |
| end?: string | null, | |
| start: string | null, | |
| end: string | null, |
| mainPresets.unshift(...DEFAULT_TIME_PRESETS); | ||
| } | ||
| mainTab.presets = filterPresets(mainPresets, minValue); | ||
| mainTab.presets = filterPresets(mainPresets, minValue, allowNullableValues); |
Collaborator
There was a problem hiding this comment.
Do we need to filter DEFAULT_OTHERS_PRESETS with allowNullableValues?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the CLA available at: [https://yandex.ru/legal/cla/?lang=en]