Skip to content

Commit

Permalink
Merge pull request #3948 from kelatev/master
Browse files Browse the repository at this point in the history
fix: always show date select
  • Loading branch information
martijnrusschen committed Jul 11, 2023
2 parents ac61b7c + 7b7b54f commit a7cc64f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export default class DatePicker extends React.Component {
showFourColumnMonthYearPicker: PropTypes.bool,
showYearPicker: PropTypes.bool,
showQuarterYearPicker: PropTypes.bool,
showDateSelect: PropTypes.bool,
showTimeSelect: PropTypes.bool,
showTimeSelectOnly: PropTypes.bool,
timeFormat: PropTypes.string,
Expand Down Expand Up @@ -538,7 +539,9 @@ export default class DatePicker extends React.Component {
this.props.onChangeRaw(event);
}
this.setSelected(date, event, false, monthSelectedIn);
this.setState({ isRenderAriaLiveMessage: true });
if (this.props.showDateSelect) {
this.setState({ isRenderAriaLiveMessage: true });
}
if (!this.props.shouldCloseOnSelect || this.props.showTimeSelect) {
this.setPreSelection(date);
} else if (!this.props.inline) {
Expand Down Expand Up @@ -982,6 +985,7 @@ export default class DatePicker extends React.Component {
weekDayClassName={this.props.weekDayClassName}
monthClassName={this.props.monthClassName}
timeClassName={this.props.timeClassName}
showDateSelect={this.props.showDateSelect}
showTimeSelect={this.props.showTimeSelect}
showTimeSelectOnly={this.props.showTimeSelectOnly}
onTimeChange={this.handleTimeChange}
Expand Down Expand Up @@ -1101,7 +1105,7 @@ export default class DatePicker extends React.Component {
aria-live="polite"
className="react-datepicker__aria-live"
>
{this.state.isRenderAriaLiveMessage && ariaLiveMessage}
{ariaLiveMessage}
</span>
);
};
Expand Down Expand Up @@ -1201,7 +1205,7 @@ export default class DatePicker extends React.Component {
<path d="M96 32V64H48C21.5 64 0 85.5 0 112v48H448V112c0-26.5-21.5-48-48-48H352V32c0-17.7-14.3-32-32-32s-32 14.3-32 32V64H160V32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192H0V464c0 26.5 21.5 48 48 48H400c26.5 0 48-21.5 48-48V192z" />
</svg>
)}
{this.renderAriaLiveRegion()}
{this.state.isRenderAriaLiveMessage && this.renderAriaLiveRegion()}
{this.renderDateInput()}
{this.renderClearButton()}
</div>
Expand Down
4 changes: 2 additions & 2 deletions test/datepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ describe("DatePicker", () => {
describe("should render aria live region after date selection", () => {
it("should have correct format if datepicker does not contain time", () => {
const datePicker = TestUtils.renderIntoDocument(
<DatePicker selected={utils.newDate()} />
<DatePicker showDateSelect selected={utils.newDate()} />
);
const dateInput = datePicker.input;

Expand All @@ -2081,7 +2081,7 @@ describe("DatePicker", () => {

it("should have correct format if datepicker contains time", () => {
const datePicker = TestUtils.renderIntoDocument(
<DatePicker showTimeInput selected={utils.newDate()} />
<DatePicker showTimeInput showDateSelect selected={utils.newDate()} />
);
const dateInput = datePicker.input;

Expand Down

0 comments on commit a7cc64f

Please sign in to comment.