-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Labs] Timezone Picker #1568
[Labs] Timezone Picker #1568
Conversation
Docs nitsPreview: documentation | table |
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.
So. Good.
Fix lintsPreview: documentation | table |
Timezone picker testsPreview: documentation | table |
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.
(check all my comments--not sure they'll all appear on the diff cuz I created them from the "View changes" partial diff view)
private handleShowLocalTimezoneChange = handleBooleanChange((showLocalTimezone) => | ||
this.setState({ showLocalTimezone })); | ||
private handleDisabledChange = handleBooleanChange(disabled => this.setState({ disabled })); | ||
private handleShowLocalTimezoneChange = handleBooleanChange(showLocalTimezone => |
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.
please always wrap params in parens. this should be a lint failure...
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.
no, this is the prettier standard
public componentWillReceiveProps(nextProps: ISelectProps<T>) { | ||
const { inputProps: nextInputProps = {} } = nextProps; | ||
if (nextInputProps.value !== undefined && this.state.query !== nextInputProps.value) { | ||
this.setState({ query: nextInputProps.value }); |
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.
nice! this seems like a valuable fix and could use a unit test (since Select
has actual coverage).
in fact you could go so far as to pull this change to a separate PR focused solely on supporting controlled input value.
though in truth we probably want an obvious query
prop instead of inputProps.value
?
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.
Going to start on this in a separate PR
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.
@@ -32,7 +32,7 @@ export function formatTimezone( | |||
const { abbreviation, offsetAsString } = getTimezoneMetadata(timezone, date); | |||
switch (displayFormat) { | |||
case TimezoneDisplayFormat.ABBREVIATION: | |||
// Fall back to the offset in regions where there is no abbreviation. | |||
// Fall back to the offset when there is no abbreviation. | |||
return abbreviation ? abbreviation : offsetAsString; |
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.
prefer to avoid implicit boolean coercion. abbreviation === undefined ? default : actual
key: string; | ||
/** Text for the timezone. */ |
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.
blank line after each property, before the next doc comment.
@@ -23,9 +23,7 @@ export function getTimezoneMetadata(timezone: string, date: Date): ITimezoneMeta | |||
const offsetAsString = zonedDate.format("Z"); | |||
const abbreviation = getAbbreviation(timezone, timestamp); | |||
// TODO: amend moment-timezone typings to include the population field |
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.
issue to track this? in moment's repo
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.
filteredItems.push(item); | ||
seenItem[key] = true; | ||
} | ||
} |
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.
please add code comments explaining what lines 62-75 are doing... I can't follow and I don't trust it.
it("clicking on button target opens popover", () => { | ||
const timezonePicker = mount(<TimezonePicker popoverProps={{ inline: true }} />); | ||
const button = timezonePicker.find(Button); | ||
button.simulate("click"); |
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.
if you don't need a reference later then no need to make a variable.
timezonePicker.find(Button).simulate("click");
it("placeholder prop changes the filter placeholder text", () => { | ||
const placeholder = "test placeholder"; | ||
const timezonePicker = shallow( | ||
<TimezonePicker popoverProps={{ isOpen: true, inline: true }} inputProps={{ placeholder }} />, |
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.
popoverProps={POPOVER_PROPS}
one object to rule them all?
assert.strictEqual(firstItem.timezone, moment.tz.guess()); | ||
}); | ||
|
||
it("does not render local timezone at top of item list if show local timezone is disabled", () => { |
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.
use prop name in test name: if showLocalTimezone=false
this comment applies widely to this file.
@## JavaScript API | ||
|
||
[Moment Timezone](http://momentjs.com/timezone/) is used internally | ||
for the list of available timezones and timezone metadata. |
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.
this line belongs at the end of the section, not the beginning: it's an implementation detail, not relevant to usage.
Add link to PR for official typings
@cmslewis Ya, it appears that select has the behavior that if an earlier query matched an item (est5edt in your case), that value stays selected even when a longer query has a different first item. I would expect the first item slot to remain active instead of jumping half-way down the list. We should distinguish between whether the user actually activated an item vs us just activating the first item by default. Made it so est shows up first. 2b37613 |
Fix testsPreview: documentation | table |
Concatenate item query candidates for better rankingPreview: documentation | table |
Fixes part of #890
Out of scope for this PR: Incorporating with the other datetime components
Checklist
Changes proposed in this pull request:
Timezone select component