Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allows selecting the end date first for unattached vertically oriented datepickers #121

Merged
merged 1 commit into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/DateRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ export default class DateRangePicker extends React.Component {
}

onEndDateFocus() {
const { startDate, onFocusChange, orientation, disabled } = this.props;
const { startDate, onFocusChange, withFullScreenPortal, disabled } = this.props;

if (!startDate && orientation === VERTICAL_ORIENTATION && !disabled) {
// Since the vertical datepicker is full screen, we never want to focus the end date first
if (!startDate && withFullScreenPortal && !disabled) {
Copy link
Member

Choose a reason for hiding this comment

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

do we want to keep this as semver-minor by leaving the vertical orientation check in place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

well but the old behavior was like, broken. So I think this needs to stay.

// When the datepicker is full screen, we never want to focus the end date first
// because there's no indication that that is the case once the datepicker is open and it
// might confuse the user
onFocusChange(START_DATE);
Expand Down
4 changes: 2 additions & 2 deletions test/components/DateRangePicker_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,12 @@ describe('DateRangePicker', () => {
});
});

describe('props.orientation = VERTICAL_ORIENTATION', () => {
describe('props.withFullScreenPortal is truthy', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the test @ljharb

it('calls props.onFocusChange once with arg START_DATE', () => {
const onFocusChangeStub = sinon.stub();
const wrapper = shallow(
<DateRangePicker
orientation={VERTICAL_ORIENTATION}
withFullScreenPortal
onFocusChange={onFocusChangeStub}
/>
);
Expand Down