Skip to content

Commit

Permalink
Address some issues introduced by the a11y PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Maja Wichrowska committed Apr 27, 2017
1 parent 3815516 commit e301ced
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 25 deletions.
2 changes: 1 addition & 1 deletion css/CalendarMonth.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

&:first-of-type {
position: absolute;
z-index: -1;
z-index: $react-dates-z-index - 1;
opacity: 0;
pointer-events: none;
}
Expand Down
4 changes: 2 additions & 2 deletions css/CalendarMonthGrid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

.CalendarMonthGrid {
background: $react-dates-color-white;
z-index: 0;
z-index: $react-dates-z-index;
text-align: left;
}

.CalendarMonthGrid--animating {
-webkit-transition: -webkit-transform 0.2s ease-in-out;
-moz-transition: -moz-transform 0.2s ease-in-out;
transition: transform 0.2s ease-in-out;
z-index: 1;
z-index: $react-dates-z-index + 1;
}

.CalendarMonthGrid--horizontal {
Expand Down
2 changes: 1 addition & 1 deletion css/DateInput.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $caret-top: $react-dates-spacing-vertical-picker - $react-dates-width-tooltip-ar
border: $react-dates-width-tooltip-arrow / 2 solid transparent;
border-top: 0;
left: 22px;
z-index: 2;
z-index: $react-dates-z-index + 2;
}

.DateInput--with-caret::before {
Expand Down
4 changes: 2 additions & 2 deletions css/DateRangePicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

.DateRangePicker__picker {
z-index: 1;
z-index: $react-dates-z-index + 1;
background-color: $react-dates-color-white;
position: absolute;
top: $react-dates-spacing-vertical-picker;
Expand Down Expand Up @@ -58,7 +58,7 @@
top: 0;
right: 0;
padding: 15px;
z-index: 2;
z-index: $react-dates-z-index + 2;

svg {
height: 15px;
Expand Down
2 changes: 1 addition & 1 deletion css/DayPicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
color: $react-dates-color-placeholder-text;
position: absolute;
top: 62px;
z-index: 2;
z-index: $react-dates-z-index + 2;
padding: 0 13px;
text-align: left;

Expand Down
17 changes: 10 additions & 7 deletions css/DayPickerKeyboardShortcuts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
.DayPickerKeyboardShortcuts__show {
width: 22px;
position: absolute;
z-index: $react-dates-z-index + 2;
}

.DayPickerKeyboardShortcuts__show--bottom-right {
border-top: 26px solid $react-dates-color-white;
border-top: 26px solid transparent;
border-right: 33px solid $react-dates-color-primary;
bottom: 0;
right: 0;
Expand All @@ -36,7 +37,7 @@
}

.DayPickerKeyboardShortcuts__show--top-right {
border-bottom: 26px solid $react-dates-color-white;
border-bottom: 26px solid transparent;
border-right: 33px solid $react-dates-color-primary;
top: 0;
right: 0;
Expand All @@ -52,7 +53,7 @@
}

.DayPickerKeyboardShortcuts__show--top-left {
border-bottom: 26px solid $react-dates-color-white;
border-bottom: 26px solid transparent;
border-left: 33px solid $react-dates-color-primary;
top: 0;
left: 0;
Expand All @@ -73,6 +74,7 @@
}

.DayPickerKeyboardShortcuts__panel {
overflow: auto;
background: $react-dates-color-white;
border: 1px solid $react-dates-color-border;
border-radius: 2px;
Expand All @@ -81,7 +83,7 @@
bottom: 0;
right: 0;
left: 0;
z-index: 2;
z-index: $react-dates-z-index + 2;
padding: 22px;
margin: 33px;
}
Expand All @@ -102,7 +104,7 @@
position: absolute;
right: 22px;
top: 22px;
z-index: 2;
z-index: $react-dates-z-index + 2;

svg {
height: 15px;
Expand All @@ -126,7 +128,6 @@

.KeyboardShortcutRow__key-container {
display: inline-block;
width: 15%;
white-space: nowrap;
text-align: right;
margin-right: 6px;
Expand All @@ -141,7 +142,9 @@
}

.KeyboardShortcutRow__action {
display: inline-block;
display: inline;
word-break: break-word;
margin-left: 8px;
}

.DayPickerKeyboardShortcuts__panel--block {
Expand Down
4 changes: 2 additions & 2 deletions css/DayPickerNavigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
border-radius: 3px;
padding: 6px 9px;
top: 18px;
z-index: 2;
z-index: $react-dates-z-index + 2;
position: absolute;
}

Expand Down Expand Up @@ -64,7 +64,7 @@
left: 0;
height: 52px;
width: 100%;
z-index: 2;
z-index: $react-dates-z-index + 2;

.DayPickerNavigation__prev,
.DayPickerNavigation__next {
Expand Down
4 changes: 2 additions & 2 deletions css/SingleDatePicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

.SingleDatePicker__picker {
z-index: 1;
z-index: $react-dates-z-index + 1;
background-color: $react-dates-color-white;
position: absolute;
top: $react-dates-spacing-vertical-picker;
Expand Down Expand Up @@ -47,7 +47,7 @@
top: 0;
right: 0;
padding: 15px;
z-index: 2;
z-index: $react-dates-z-index + 2;

svg {
height: 15px;
Expand Down
2 changes: 2 additions & 0 deletions css/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ $react-dates-color-placeholder-text: #757575 !default;
$react-dates-color-text: #484848 !default;
$react-dates-color-text-focus: #007a87 !default;
$react-dates-color-focus: #99ede6 !default;

$react-dates-z-index: 0 !default;
3 changes: 3 additions & 0 deletions src/components/DateRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const defaultProps = {
keepOpenOnDateSelect: false,
reopenPickerOnClearDates: false,
renderCalendarInfo: null,
hideKeyboardShortcutsPanel: false,
daySize: DAY_SIZE,

// navigation related props
Expand Down Expand Up @@ -298,6 +299,7 @@ export default class DateRangePicker extends React.Component {
renderDay,
renderCalendarInfo,
initialVisibleMonth,
hideKeyboardShortcutsPanel,
customCloseIcon,
onClose,
phrases,
Expand Down Expand Up @@ -336,6 +338,7 @@ export default class DateRangePicker extends React.Component {
withPortal={withPortal || withFullScreenPortal}
daySize={daySize}
initialVisibleMonth={initialVisibleMonthThunk}
hideKeyboardShortcutsPanel={hideKeyboardShortcutsPanel}
navPrev={navPrev}
navNext={navNext}
minimumNights={minimumNights}
Expand Down
19 changes: 15 additions & 4 deletions src/components/DayPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const propTypes = forbidExtraProps({
hidden: PropTypes.bool,
initialVisibleMonth: PropTypes.func,
renderCalendarInfo: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,

// navigation props
Expand Down Expand Up @@ -84,6 +85,7 @@ export const defaultProps = {
hidden: false,
initialVisibleMonth: () => moment(),
renderCalendarInfo: null,
hideKeyboardShortcutsPanel: false,
daySize: DAY_SIZE,

// navigation props
Expand Down Expand Up @@ -385,6 +387,7 @@ export default class DayPicker extends React.Component {
this.setState({
monthTransition: PREV_TRANSITION,
translationValue,
focusedDate: null,
nextFocusedDate,
});
}
Expand All @@ -401,6 +404,7 @@ export default class DayPicker extends React.Component {
this.setState({
monthTransition: NEXT_TRANSITION,
translationValue,
focusedDate: null,
nextFocusedDate,
});
}
Expand Down Expand Up @@ -488,7 +492,13 @@ export default class DayPicker extends React.Component {
}

updateStateAfterMonthTransition() {
const { currentMonth, monthTransition, focusedDate, nextFocusedDate } = this.state;
const {
currentMonth,
monthTransition,
focusedDate,
nextFocusedDate,
withMouseInteractions,
} = this.state;

if (!monthTransition) return;

Expand All @@ -502,7 +512,7 @@ export default class DayPicker extends React.Component {
let newFocusedDate = null;
if (nextFocusedDate) {
newFocusedDate = nextFocusedDate;
} else if (focusedDate) {
} else if (!focusedDate && !withMouseInteractions) {
newFocusedDate = this.getFocusedDay(newMonth);
}

Expand All @@ -522,7 +532,7 @@ export default class DayPicker extends React.Component {
}, () => {
// we don't want to focus on the relevant calendar day after a month transition
// if the user is navigating around using a mouse
if (this.state.withMouseInteractions) {
if (withMouseInteractions) {
const activeElement = getActiveElement();
if (activeElement && activeElement !== document.body) {
activeElement.blur();
Expand Down Expand Up @@ -674,6 +684,7 @@ export default class DayPicker extends React.Component {
onDayMouseLeave,
renderDay,
renderCalendarInfo,
hideKeyboardShortcutsPanel,
onOutsideClick,
monthFormat,
daySize,
Expand Down Expand Up @@ -792,7 +803,7 @@ export default class DayPicker extends React.Component {
{verticalScrollable && this.renderNavigation()}
</div>

{!isTouch &&
{!isTouch && !hideKeyboardShortcutsPanel &&
<DayPickerKeyboardShortcuts
block={this.isVertical() && !withPortal}
buttonLocation={keyboardShortcutButtonLocation}
Expand Down
5 changes: 4 additions & 1 deletion src/components/DayPickerRangeController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const propTypes = forbidExtraProps({
orientation: ScrollableOrientationShape,
withPortal: PropTypes.bool,
initialVisibleMonth: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,

navPrev: PropTypes.node,
Expand Down Expand Up @@ -87,7 +88,7 @@ const defaultProps = {
numberOfMonths: 1,
orientation: HORIZONTAL_ORIENTATION,
withPortal: false,

hideKeyboardShortcutsPanel: false,
initialVisibleMonth: DayPickerDefaultProps.initialVisibleMonth,
daySize: DAY_SIZE,

Expand Down Expand Up @@ -315,6 +316,7 @@ export default class DayPickerRangeController extends React.Component {
withPortal,
enableOutsideDays,
initialVisibleMonth,
hideKeyboardShortcutsPanel,
daySize,
focusedInput,
renderDay,
Expand Down Expand Up @@ -381,6 +383,7 @@ export default class DayPickerRangeController extends React.Component {
navNext={navNext}
renderDay={renderDay}
renderCalendarInfo={renderCalendarInfo}
hideKeyboardShortcutsPanel={hideKeyboardShortcutsPanel}
isFocused={isFocused}
getFirstFocusableDay={this.getFirstFocusableDay}
onBlur={onBlur}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SingleDatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const defaultProps = {
keepOpenOnDateSelect: false,
reopenPickerOnClearDate: false,
renderCalendarInfo: null,
hideKeyboardShortcutsPanel: false,
daySize: DAY_SIZE,

// navigation related props
Expand Down Expand Up @@ -392,6 +393,7 @@ export default class SingleDatePicker extends React.Component {
renderCalendarInfo,
date,
initialVisibleMonth,
hideKeyboardShortcutsPanel,
customCloseIcon,
phrases,
daySize,
Expand Down Expand Up @@ -434,6 +436,7 @@ export default class SingleDatePicker extends React.Component {
withPortal={withPortal || withFullScreenPortal}
hidden={!focused}
initialVisibleMonth={initialVisibleMonthThunk}
hideKeyboardShortcutsPanel={hideKeyboardShortcutsPanel}
navPrev={navPrev}
navNext={navNext}
renderDay={renderDay}
Expand Down
1 change: 1 addition & 0 deletions src/shapes/DateRangePickerShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default {
keepOpenOnDateSelect: PropTypes.bool,
reopenPickerOnClearDates: PropTypes.bool,
renderCalendarInfo: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,

// navigation related props
navPrev: PropTypes.node,
Expand Down
1 change: 1 addition & 0 deletions src/shapes/SingleDatePickerShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
keepOpenOnDateSelect: PropTypes.bool,
reopenPickerOnClearDate: PropTypes.bool,
renderCalendarInfo: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,

// navigation related props
Expand Down
6 changes: 6 additions & 0 deletions stories/DateRangePicker_calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ storiesOf('DRP - Calendar Props', module)
)}
autoFocus
/>
))
.addWithInfo('with keyboard shorcuts panel hidden', () => (
<DateRangePickerWrapper
hideKeyboardShortcutsPanel
autoFocus
/>
));
6 changes: 6 additions & 0 deletions stories/SingleDatePicker_calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ storiesOf('SDP - Calendar Props', module)
)}
autoFocus
/>
))
.addWithInfo('with keyboard shorcuts panel hidden', () => (
<SingleDatePickerWrapper
hideKeyboardShortcutsPanel
autoFocus
/>
));
Loading

0 comments on commit e301ced

Please sign in to comment.