File tree 1 file changed +25
-2
lines changed
src/components/assistants/temporal
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { bind } from 'decko';
3
3
import { Assistant } from '../../assistant' ;
4
4
import TinyDatePicker from 'tiny-date-picker' ;
5
5
import { toChar } from '../../../lib/string-util' ;
6
+ import { ENTER , TAB } from '../../../lib/keys' ;
6
7
7
8
/**
8
9
* A visual interaction mechanism for supplying values
@@ -43,13 +44,13 @@ export class DateTimeEntryAssistant extends Assistant {
43
44
if ( this . dateInput ) {
44
45
this . dateInput . setState ( {
45
46
selectedDate : newDate ,
46
- highlightedDate : newDate
47
+ hilightedDate : newDate
47
48
} ) ;
48
49
}
49
50
} else if ( this . dateInput ) {
50
51
this . dateInput . setState ( {
51
52
selectedDate : null ,
52
- highlightedDate : new Date ( )
53
+ hilightedDate : new Date ( )
53
54
} ) ;
54
55
}
55
56
}
@@ -89,6 +90,28 @@ export class DateTimeEntryAssistant extends Assistant {
89
90
this . requestRemoveArchivedValue ( idx ) ;
90
91
}
91
92
93
+ delegateEvent ( e ) {
94
+ let consumed = false ;
95
+ switch ( e . keyCode ) {
96
+ case ENTER :
97
+ case TAB :
98
+ // Use the currently "focused" date if we dont have a value
99
+ if ( this . boxedValue == null && this . dateInput && this . dateInput . state . hilightedDate ) {
100
+ this . boxedValue = this . dateInput . state . hilightedDate ;
101
+ }
102
+
103
+ this . requestTransition ( ) ;
104
+
105
+ consumed = true ;
106
+ break ;
107
+ }
108
+ if ( consumed ) {
109
+ e . stopPropagation ( ) ;
110
+ e . preventDefault ( ) ;
111
+ }
112
+ return consumed ;
113
+ }
114
+
92
115
renderArchive ( ) {
93
116
if ( this . machineState . isMultivalue ) {
94
117
return (
You can’t perform that action at this time.
0 commit comments