Skip to content

Commit c9a3c6f

Browse files
committed
Fix logic for apply default navigation button styling
1 parent 71b4e5d commit c9a3c6f

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

src/components/DayPickerNavigation.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class DayPickerNavigation extends React.PureComponent {
104104
let navPrevTabIndex = {};
105105
let navNextTabIndex = {};
106106

107-
if (!navPrevIcon) {
107+
if (!navPrevIcon && !renderNavPrevButton) {
108108
navPrevTabIndex = { tabIndex: '0' };
109109
isDefaultNavPrev = true;
110110
let Icon = isVertical ? ChevronUp : LeftArrow;
@@ -122,7 +122,7 @@ class DayPickerNavigation extends React.PureComponent {
122122
);
123123
}
124124

125-
if (!navNextIcon) {
125+
if (!navNextIcon && !renderNavNextButton) {
126126
navNextTabIndex = { tabIndex: '0' };
127127
isDefaultNavNext = true;
128128
let Icon = isVertical ? ChevronDown : RightArrow;

stories/DayPickerRangeController.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,54 @@ function renderNavNextButton(buttonProps) {
157157
);
158158
}
159159

160+
function renderNavPrevButtonForVerticalScrollable(buttonProps) {
161+
const {
162+
ariaLabel,
163+
disabled,
164+
onClick,
165+
onKeyUp,
166+
onMouseUp,
167+
} = buttonProps;
168+
169+
return (
170+
<button
171+
aria-label={ariaLabel}
172+
disabled={disabled}
173+
onClick={onClick}
174+
onKeyUp={onKeyUp}
175+
onMouseUp={onMouseUp}
176+
style={{ width: '100%', textAlign: 'center' }}
177+
type="button"
178+
>
179+
&lsaquo; Prev
180+
</button>
181+
);
182+
}
183+
184+
function renderNavNextButtonForVerticalScrollable(buttonProps) {
185+
const {
186+
ariaLabel,
187+
disabled,
188+
onClick,
189+
onKeyUp,
190+
onMouseUp,
191+
} = buttonProps;
192+
193+
return (
194+
<button
195+
aria-label={ariaLabel}
196+
disabled={disabled}
197+
onClick={onClick}
198+
onKeyUp={onKeyUp}
199+
onMouseUp={onMouseUp}
200+
style={{ width: '100%', textAlign: 'center' }}
201+
type="button"
202+
>
203+
Next &rsaquo;
204+
</button>
205+
);
206+
}
207+
160208
function renderKeyboardShortcutsButton(buttonProps) {
161209
const { ref, onClick, ariaLabel } = buttonProps;
162210

@@ -462,6 +510,20 @@ storiesOf('DayPickerRangeController', module)
462510
/>
463511
</div>
464512
)))
513+
.add('vertical scrollable with custom rendered month navigation', withInfo()(() => (
514+
<div style={{ height: 500 }}>
515+
<DayPickerRangeControllerWrapper
516+
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
517+
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
518+
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
519+
orientation={VERTICAL_SCROLLABLE}
520+
numberOfMonths={3}
521+
verticalHeight={300}
522+
renderNavPrevButton={renderNavPrevButtonForVerticalScrollable}
523+
renderNavNextButton={renderNavNextButtonForVerticalScrollable}
524+
/>
525+
</div>
526+
)))
465527
.add('with custom month navigation icons', withInfo()(() => (
466528
<DayPickerRangeControllerWrapper
467529
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}

0 commit comments

Comments
 (0)