Skip to content

Commit 486b8ee

Browse files
Matan Borenkraoutljharb
authored andcommitted
[Fix] DateRangePickerInput: customArrowIcon always overrides RTL or small icon
Fixes react-dates#1507. Fixes react-dates#1537.
1 parent 61ce499 commit 486b8ee

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/components/DateRangePickerInput.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ function DateRangePickerInput({
182182
const calendarIcon = customInputIcon || (
183183
<CalendarIcon {...css(styles.DateRangePickerInput_calendarIcon_svg)} />
184184
);
185-
186-
let arrowIcon = customArrowIcon || <RightArrow {...css(styles.DateRangePickerInput_arrow_svg)} />;
185+
let arrowIcon = <RightArrow {...css(styles.DateRangePickerInput_arrow_svg)} />;
187186
if (isRTL) arrowIcon = <LeftArrow {...css(styles.DateRangePickerInput_arrow_svg)} />;
188187
if (small) arrowIcon = '-';
188+
if (customArrowIcon) arrowIcon = customArrowIcon;
189189

190190
const closeIcon = customCloseIcon || (
191191
<CloseButton

stories/DateRangePicker_input.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ storiesOf('DRP - Input Props', module)
126126
customArrowIcon={<TestCustomArrowIcon />}
127127
/>
128128
)))
129+
.add('with custom arrow icon and RTL support', withInfo()(() => (
130+
<DateRangePickerWrapper
131+
initialStartDate={moment().add(3, 'days')}
132+
initialEndDate={moment().add(10, 'days')}
133+
customArrowIcon={<TestCustomArrowIcon />}
134+
isRTL
135+
/>
136+
)))
129137
.add('with custom close icon', withInfo()(() => (
130138
<DateRangePickerWrapper
131139
initialStartDate={moment().add(3, 'days')}

test/components/DateRangePickerInput_spec.jsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ describe('DateRangePickerInput', () => {
6969
)).dive();
7070
expect(wrapper.find('.custom-arrow-icon')).to.have.lengthOf(1);
7171
});
72+
73+
it('custom icon is rendered when in RTL mode', () => {
74+
const wrapper = shallow(
75+
<DateRangePickerInput
76+
customArrowIcon={<span className="custom-arrow-icon" />}
77+
isRTL
78+
/>,
79+
).dive();
80+
expect(wrapper.find('.custom-arrow-icon')).to.have.lengthOf(1);
81+
});
82+
83+
it('custom icon is rendered when using small mode', () => {
84+
const wrapper = shallow(
85+
<DateRangePickerInput
86+
customArrowIcon={<span className="custom-arrow-icon" />}
87+
small
88+
/>,
89+
).dive();
90+
expect(wrapper.find('.custom-arrow-icon')).to.have.lengthOf(1);
91+
});
7292
});
7393

7494
describe('props.customCloseIcon', () => {

0 commit comments

Comments
 (0)