-
Notifications
You must be signed in to change notification settings - Fork 51
Engagements #1717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Engagements #1717
Conversation
| })) | ||
| return [ANY_OPTION, ...zones] | ||
| const { timeZoneOptions, timeZoneOptionByZone } = useMemo(() => { | ||
| const optionByLabel = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[design]
The use of Map for optionByLabel is appropriate for ensuring unique labels, but the conversion of labels to lowercase (normalizedLabel) might lead to unexpected behavior if labels are case-sensitive or if different labels are intended to be distinct. Consider whether case-insensitivity is necessary and document this decision.
| const selected = [] | ||
| const seen = new Set() | ||
| timeZones.forEach((zone) => { | ||
| const option = timeZoneOptionByZone.get(zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
The selectedTimeZones logic assumes that timeZoneOptionByZone will always have a mapping for each zone. If formatTimeZoneLabel returns a falsy value or if a zone is not found in timeZoneOptionByZone, it might lead to unexpected results. Ensure that all possible zone values are covered or handle the case where a zone is not found.
| timezones.push(ANY_OPTION.value) | ||
| return | ||
| } | ||
| if (!Array.isArray(option.zones) || option.zones.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
The check !Array.isArray(option.zones) || option.zones.length === 0 is used to skip options without zones. Ensure that all valid options have non-empty zones arrays, or handle cases where zones might be empty to avoid potential issues.
| const uniqueLabels = [] | ||
| const seenLabels = new Set() | ||
| labels.forEach((label) => { | ||
| const normalized = label.toLowerCase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
Consider using label.trim().toLowerCase() to normalize labels, as this will handle cases where labels have leading or trailing whitespace differences.
No description provided.