File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -454,11 +454,10 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
454454 }
455455
456456 __addEventDelegationForClickDate ( ) {
457- const isDayCellOrButton = el =>
458- el . classList . contains ( 'calendar__day-cell' ) || el . classList . contains ( 'calendar__day-button' ) ;
457+ const isDayButton = el => el . classList . contains ( 'calendar__day-button' ) ;
459458 this . __clickDateDelegation = this . __contentWrapperElement . addEventListener ( 'click' , ev => {
460- const el = ev . composedPath ( ) [ 0 ] ;
461- if ( isDayCellOrButton ( el ) ) {
459+ const el = ev . target ;
460+ if ( isDayButton ( el ) ) {
462461 this . __dateSelectedByUser ( el . date ) ;
463462 }
464463 } ) ;
Original file line number Diff line number Diff line change @@ -204,6 +204,22 @@ describe('<lion-calendar>', () => {
204204 ) . to . equal ( true ) ;
205205 } ) ;
206206
207+ it ( 'doesn\'t send event "user-selected-date-changed" when user selects a disabled date' , async ( ) => {
208+ const dateChangedSpy = sinon . spy ( ) ;
209+ const disable15th = d => d . getDate ( ) === 15 ;
210+ const el = await fixture ( html `
211+ < lion-calendar
212+ .selectedDate ="${ new Date ( '2000/12/12' ) } "
213+ @user-selected-date-changed ="${ dateChangedSpy } "
214+ .disableDates =${ disable15th }
215+ > </ lion-calendar >
216+ ` ) ;
217+ const elObj = new CalendarObject ( el ) ;
218+ elObj . getDayEl ( 15 ) . click ( ) ;
219+ await el . updateComplete ;
220+ expect ( dateChangedSpy . called ) . to . equal ( false ) ;
221+ } ) ;
222+
207223 it ( 'exposes focusedDate getter' , async ( ) => {
208224 const el = await fixture ( html `
209225 < lion-calendar .centralDate ="${ new Date ( '2019/06/01' ) } "> </ lion-calendar >
You can’t perform that action at this time.
0 commit comments