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 tabIndex prop #401

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Displays an input field complete with custom inputs, native input, and a calenda
|returnValue|Which dates shall be passed by the calendar to the onChange function and onClick{Period} functions. Can be `"start"`, `"end"` or `"range"`. The latter will cause an array with start and end values to be passed.|`"start"`|`"range"`|
|showLeadingZeros|Whether leading zeros should be rendered in date inputs.|`false`|`true`|
|value|Input value.|n/a|<ul><li>Date: `new Date()`</li><li>An array of dates: `[new Date(2017, 0, 1), new Date(2017, 7, 1)]`</li></ul>|
|tabIndex|`tabindex` of the first input|n/a| `42`|
|yearAriaLabel|`aria-label` for the year input.|n/a|`"Year"`|
|yearPlaceholder|`aria-label` for the year input.|`"----"`|`"yyyy"`|

Expand Down
14 changes: 13 additions & 1 deletion src/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ export default class DateInput extends PureComponent {
dayAriaLabel,
dayPlaceholder,
showLeadingZeros,
tabIndex,
} = this.props;
const { day, month, year } = this.state;

Expand All @@ -479,6 +480,7 @@ export default class DateInput extends PureComponent {
month={month}
placeholder={dayPlaceholder}
showLeadingZeros={showLeadingZerosFromFormat || showLeadingZeros}
tabIndex={index === 0 ? tabIndex : undefined}
value={day}
year={year}
/>
Expand All @@ -492,6 +494,7 @@ export default class DateInput extends PureComponent {
monthAriaLabel,
monthPlaceholder,
showLeadingZeros,
tabIndex,
} = this.props;
const { month, year } = this.state;

Expand All @@ -511,6 +514,7 @@ export default class DateInput extends PureComponent {
placeholder={monthPlaceholder}
short={currentMatch.length === 3}
value={month}
tabIndex={index === 0 ? tabIndex : undefined}
year={year}
/>
);
Expand All @@ -528,13 +532,19 @@ export default class DateInput extends PureComponent {
placeholder={monthPlaceholder}
showLeadingZeros={showLeadingZerosFromFormat || showLeadingZeros}
value={month}
tabIndex={index === 0 ? tabIndex : undefined}
year={year}
/>
);
}

renderYear = (currentMatch, index) => {
const { autoFocus, yearAriaLabel, yearPlaceholder } = this.props;
const {
autoFocus,
tabIndex,
yearAriaLabel,
yearPlaceholder,
} = this.props;
const { year } = this.state;

return (
Expand All @@ -545,6 +555,7 @@ export default class DateInput extends PureComponent {
autoFocus={index === 0 && autoFocus}
inputRef={this.yearInput}
placeholder={yearPlaceholder}
tabIndex={index === 0 ? tabIndex : undefined}
value={year}
valueType={this.valueType}
/>
Expand Down Expand Up @@ -640,6 +651,7 @@ DateInput.propTypes = {
required: PropTypes.bool,
returnValue: PropTypes.oneOf(['start', 'end', 'range']),
showLeadingZeros: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.oneOfType([
isValue,
PropTypes.arrayOf(isValue),
Expand Down
1 change: 1 addition & 0 deletions src/DateInput/DayInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ DayInput.propTypes = {
placeholder: PropTypes.string,
required: PropTypes.bool,
showLeadingZeros: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.string,
year: PropTypes.string,
};
3 changes: 3 additions & 0 deletions src/DateInput/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export default function Input({
required,
showLeadingZeros,
step,
tabIndex,
value,
}) {
const hasLeadingZero = (
Expand Down Expand Up @@ -151,6 +152,7 @@ export default function Input({
ref={mergeRefs(updateInputWidth, updateInputWidthOnFontLoad, inputRef)}
required={required}
step={step}
tabIndex={tabIndex}
type="number"
value={value !== null ? value : ''}
/>,
Expand All @@ -174,5 +176,6 @@ Input.propTypes = {
required: PropTypes.bool,
showLeadingZeros: PropTypes.bool,
step: PropTypes.number,
tabIndex: PropTypes.number,
value: PropTypes.string,
};
1 change: 1 addition & 0 deletions src/DateInput/MonthInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ MonthInput.propTypes = {
placeholder: PropTypes.string,
required: PropTypes.bool,
showLeadingZeros: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.string,
year: PropTypes.string,
};
1 change: 1 addition & 0 deletions src/DateInput/MonthSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ MonthSelect.propTypes = {
placeholder: PropTypes.string,
required: PropTypes.bool,
short: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.string,
year: PropTypes.string,
};
1 change: 1 addition & 0 deletions src/DateInput/YearInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ YearInput.propTypes = {
onKeyUp: PropTypes.func,
placeholder: PropTypes.string,
required: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.string,
valueType: isValueType,
};
3 changes: 3 additions & 0 deletions src/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default class DatePicker extends PureComponent {
required,
returnValue,
showLeadingZeros,
tabIndex,
value,
yearAriaLabel,
yearPlaceholder,
Expand Down Expand Up @@ -192,6 +193,7 @@ export default class DatePicker extends PureComponent {
required={required}
returnValue={returnValue}
showLeadingZeros={showLeadingZeros}
tabIndex={tabIndex}
value={valueFrom}
/>
{clearIcon !== null && (
Expand Down Expand Up @@ -368,6 +370,7 @@ DatePicker.propTypes = {
required: PropTypes.bool,
returnValue: PropTypes.oneOf(['start', 'end', 'range']),
showLeadingZeros: PropTypes.bool,
tabIndex: PropTypes.number,
value: PropTypes.oneOfType([
isValue,
PropTypes.arrayOf(isValue),
Expand Down