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

Add customCloseIcon prop #356

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Conversation

moonboots
Copy link
Collaborator

@majapw @ljharb

Adds a customCloseIcon prop to allow overriding the default <CloseButton />. I matched the behavior of customArrowIcon: default prop of null, fallback to original component inside render, and a wrapping css class.

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.04%) to 81.802% when pulling 48e136c on moonboots:custom-close-icon into 04d08d4 on airbnb:master.

@@ -273,7 +277,9 @@ export default class DateRangePicker extends React.Component {
<span className="screen-reader-only">
{this.props.phrases.closeDatePicker}
</span>
<CloseButton />
<div className="DateRangePickerInput__close">
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class name is wrong. You're not inside the input.

padding: '3px',
}}
>
{'X'}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can just be X no?

showClearDates
customCloseIcon={<span className="custom-close-icon" />}
/>);
expect(wrapper.find('.DateRangePickerInput__calendar-icon .custom-close-icon'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should fail... why would it be under .DateRangePickerInput__calendar-icon? Why isn't this failing?

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

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

I'm concerned about the test, plus we need parallel tests for the SingleDatePicker components.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 82.318% when pulling 09fd248 on moonboots:custom-close-icon into 43badcf on airbnb:master.

@moonboots moonboots force-pushed the custom-close-icon branch 3 times, most recently from f30d5fb to 3f95071 Compare March 7, 2017 01:06
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.318% when pulling 3f95071 on moonboots:custom-close-icon into 9704b74 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.318% when pulling 3f95071 on moonboots:custom-close-icon into 9704b74 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.318% when pulling 3f95071 on moonboots:custom-close-icon into 9704b74 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.146% when pulling 0a31762 on moonboots:custom-close-icon into 130e542 on airbnb:master.

@moonboots
Copy link
Collaborator Author

@majapw I've added a corresponding spec for SingleDatePicker. The spec you pointed out wasn't failing because it accidentally didn't have any assertions, only a dangling expect(..);, fixed now.

showClearDates
customCloseIcon={<span className="custom-close-icon" />}
/>);
expect(wrapper.find('.DateRangePickerInput__calendar-icon .custom-close-icon'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You now have the same problem here in this spec...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, fixed

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.146% when pulling 9f18afd on moonboots:custom-close-icon into 130e542 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 82.146% when pulling 9f18afd on moonboots:custom-close-icon into 130e542 on airbnb:master.

@majapw majapw merged commit eab9c04 into react-dates:master Mar 9, 2017
@moonboots moonboots deleted the custom-close-icon branch March 9, 2017 19:08
@zeemawn
Copy link

zeemawn commented Mar 21, 2017

Correct me if I'm wrong, but shouldn't this whole thing rather be called "custom CLEAR icon"?
The 'X' might look like a close-icon, but its function is to clear the dates, isn't it?
(Besides that, it would be nice to have an actual close-button)

@ljharb
Copy link
Member

ljharb commented Mar 21, 2017

It closes the datepicker, it doesn't clear the dates.

@majapw
Copy link
Collaborator

majapw commented Mar 21, 2017

It actually does both... We overload the icon in use, so uh, I get the Q

@ljharb
Copy link
Member

ljharb commented Mar 21, 2017

Lol well there you go

@ljharb
Copy link
Member

ljharb commented Mar 23, 2017

@majapw can we unoverload them?

@interactivejohn
Copy link

interactivejohn commented Apr 9, 2018

I ran into the same issue as @zeemawn. I spent a good couple hours thinking that I could add a custom close icon to the default state, only to find out that it was only implemented for the showClearDate and withFullScreenPortal props. Maybe something can be added to the README that explains where the customCloseIcon is implemented? Meanwhile I will fork this package and start working on implementing a showDefaultCloseIcon for the DatePicker as requested above (I also need it for a project).

@ljharb ljharb mentioned this pull request Apr 12, 2019
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.

6 participants