Skip to content

Add customCloseIcon prop#356

Merged
majapw merged 2 commits intoreact-dates:masterfrom
moonboots:custom-close-icon
Mar 9, 2017
Merged

Add customCloseIcon prop#356
majapw merged 2 commits intoreact-dates:masterfrom
moonboots:custom-close-icon

Conversation

@moonboots
Copy link
Copy Markdown
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
Copy Markdown

Coverage Status

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

Comment thread src/components/DateRangePicker.jsx Outdated
{this.props.phrases.closeDatePicker}
</span>
<CloseButton />
<div className="DateRangePickerInput__close">
Copy link
Copy Markdown
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.

Comment thread stories/DateRangePicker_input.js Outdated
padding: '3px',
}}
>
{'X'}
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@moonboots moonboots force-pushed the custom-close-icon branch from 48e136c to 09fd248 Compare March 6, 2017 23:28
@coveralls
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops, fixed

@moonboots moonboots force-pushed the custom-close-icon branch from 0a31762 to 6d45150 Compare March 9, 2017 18:12
@coveralls
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Member

ljharb commented Mar 21, 2017

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

@majapw
Copy link
Copy Markdown
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
Copy Markdown
Member

ljharb commented Mar 21, 2017

Lol well there you go

@ljharb
Copy link
Copy Markdown
Member

ljharb commented Mar 23, 2017

@majapw can we unoverload them?

@interactivejohn
Copy link
Copy Markdown

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