Skip to content
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

DateInput popoverProps #978

Merged
merged 5 commits into from
Apr 12, 2017
Merged

DateInput popoverProps #978

merged 5 commits into from
Apr 12, 2017

Conversation

giladgray
Copy link
Contributor

@giladgray giladgray commented Apr 12, 2017

Fixes #560, #974

Changes proposed in this pull request:

  • new popoverProps prop proxied to Popover
  • ❌ deprecate popoverPosition

@blueprint-bot
Copy link

no default prop value; assign it when deconstructing

Preview: documentation
Coverage: core | datetime

*/
popoverPosition?: Position;

/**
* Props to pass to the `Popover`. Note that `content` cannot be changed.
*/
popoverProps?: Partial<IPopoverProps>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this accepts almost any value because it's equal to {}. you should at least combine it with & object to limit it to non-primitive types.

@@ -174,6 +181,7 @@ export class DateInput extends AbstractComponent<IDateInputProps, IDateInputStat
{...sharedProps}
timePickerProps={{ precision: this.props.timePrecision }}
/>;
const { popoverProps = {} } = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use defaultProps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giladgray Minor thoughts/requests but overall looks good. Will wait for answers before approving.

{...popoverProps}
content={popoverContent}
onClose={this.handleClosePopover}
popoverClassName={classNames("pt-dateinput-popover", popoverProps.popoverClassName)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giladgray is it still possible to add custom classes to the popover via popoverProps? We should allow for that in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i'm not mistaken, that is the purpose of this line (and why it comes after the spread)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's also popoverProps.className which is covered by spread

@@ -182,13 +190,14 @@ export class DateInput extends AbstractComponent<IDateInputProps, IDateInputStat
return (
<Popover
autoFocus={false}
content={popoverContent}
enforceFocus={false}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of these should not be overridable based on my experience with #940, particularly autoFocus and enforceFocus. Led to really weird UX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

truth, thanks for tip

assert.strictEqual(popover.prop("inline"), true);
assert.strictEqual(popover.prop("position"), Position.TOP);
assert.isTrue(popoverWillOpen.calledOnce);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also like to see some tests asserting which props are not overridable. See https://github.com/palantir/blueprint/pull/940/files, e.g.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good call

@@ -100,10 +101,16 @@ export interface IDateInputProps extends IDatePickerBaseProps, IProps {
/**
* The position the date popover should appear in relative to the input box.
* @default Position.BOTTOM
* @deprecated since v1.15.0, use `popoverProps.position`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We should add this message to DateRangeInput in #940 and also NumericInput if we move that component to support IInputProps. (Separate PRs of course)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand the request here? DRI does not have any deprecated props, nor does NI.

@blueprint-bot
Copy link

props extends object, move spread, test locked props

Preview: documentation
Coverage: core | datetime

@blueprint-bot
Copy link

add deprecation warning to DateInput

Preview: documentation
Coverage: core | datetime

@giladgray giladgray merged commit e03279c into master Apr 12, 2017
@giladgray giladgray deleted the gg/date-input-popover-props branch April 12, 2017 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants