File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import {MdDatepickerIntl} from './datepicker-intl';
9
9
template : '' ,
10
10
styleUrls : [ 'datepicker-toggle.css' ] ,
11
11
host : {
12
+ '[attr.type]' : 'type' ,
12
13
'[class.mat-datepicker-toggle]' : 'true' ,
13
14
'[attr.aria-label]' : '_intl.openCalendarLabel' ,
14
15
'(click)' : '_open($event)' ,
@@ -17,8 +18,12 @@ import {MdDatepickerIntl} from './datepicker-intl';
17
18
changeDetection : ChangeDetectionStrategy . OnPush ,
18
19
} )
19
20
export class MdDatepickerToggle < D > {
21
+ /** Datepicker instance that the button will toggle. */
20
22
@Input ( 'mdDatepickerToggle' ) datepicker : MdDatepicker < D > ;
21
23
24
+ /** Type of the button. */
25
+ @Input ( ) type : string = 'button' ;
26
+
22
27
@Input ( 'matDatepickerToggle' )
23
28
get _datepicker ( ) { return this . datepicker ; }
24
29
set _datepicker ( v : MdDatepicker < D > ) { this . datepicker = v ; }
Original file line number Diff line number Diff line change @@ -374,15 +374,20 @@ describe('MdDatepicker', () => {
374
374
fixture . detectChanges ( ) ;
375
375
} ) ) ;
376
376
377
- it ( 'should open calendar when toggle clicked' , async ( ( ) => {
377
+ it ( 'should open calendar when toggle clicked' , ( ) => {
378
378
expect ( document . querySelector ( 'md-dialog-container' ) ) . toBeNull ( ) ;
379
379
380
380
let toggle = fixture . debugElement . query ( By . css ( 'button' ) ) ;
381
381
dispatchMouseEvent ( toggle . nativeElement , 'click' ) ;
382
382
fixture . detectChanges ( ) ;
383
383
384
384
expect ( document . querySelector ( 'md-dialog-container' ) ) . not . toBeNull ( ) ;
385
- } ) ) ;
385
+ } ) ;
386
+
387
+ it ( 'should set the `button` type on the trigger to prevent form submissions' , ( ) => {
388
+ let toggle = fixture . debugElement . query ( By . css ( 'button' ) ) . nativeElement ;
389
+ expect ( toggle . getAttribute ( 'type' ) ) . toBe ( 'button' ) ;
390
+ } ) ;
386
391
} ) ;
387
392
388
393
describe ( 'datepicker inside input-container' , ( ) => {
You can’t perform that action at this time.
0 commit comments