diff --git a/src/DayPicker.js b/src/DayPicker.js index ca5b1ee99e..a6216c5afe 100644 --- a/src/DayPicker.js +++ b/src/DayPicker.js @@ -435,17 +435,15 @@ export default class DayPicker extends Component { React.createElement(navbarElement, props); } renderDayInMonth(day, month) { - let dayModifiers = []; - if (DateUtils.isSameDay(day, new Date())) { + const propModifiers = Helpers.getModifiersFromProps(this.props); + const dayModifiers = Helpers.getModifiersForDay(day, propModifiers); + if (DateUtils.isSameDay(day, new Date()) && + !Object.prototype.hasOwnProperty.call(propModifiers, this.props.classNames.today)) { dayModifiers.push(this.props.classNames.today); } if (day.getMonth() !== month.getMonth()) { dayModifiers.push(this.props.classNames.outside); } - dayModifiers = [ - ...dayModifiers, - ...Helpers.getModifiersForDay(day, Helpers.getModifiersFromProps(this.props)), - ]; const isOutside = day.getMonth() !== month.getMonth(); let tabIndex = null; diff --git a/test/daypicker/modifiers.js b/test/daypicker/modifiers.js index 47f03e094f..d92904700b 100644 --- a/test/daypicker/modifiers.js +++ b/test/daypicker/modifiers.js @@ -65,4 +65,20 @@ describe('DayPicker’s day modifiers', () => { expect(wrapper.find('.DayPicker-Day--none')).to.have.length(0); expect(wrapper.find('.DayPicker-Day--all')).to.have.length(35); }); + it('should show "today" as something other than the current day', () => { + const newToday = new Date(); + newToday.setDate((new Date()).getDate() + 1); + newToday.setMonth((new Date()).getMonth()); + + const modifiers = { + today: newToday, + }; + const wrapper = mount( + , + ); + expect(wrapper.find('.DayPicker-Day--today')).to.have.text(newToday.getDate()); + }); });