File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/components/RecipientsInput Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,20 @@ class RecipientsInput extends Component {
119119 }
120120 } ;
121121
122- this . handleHotKey = ( e ) => {
122+ this . isSplitter = ( e ) => {
123+ if (
124+ e . key === ',' || e . key === ';' || e . key === 'Enter' ||
125+ ( e . key === 'Unidentified' && // for Safari (FF cannot rely on keyCode...)
126+ ( e . keyCode === 186 || // semicolon
127+ e . keyCode === 188 || // comma
128+ e . keyCode === 13 ) ) // enter
129+ ) {
130+ return true ;
131+ }
132+ return false ;
133+ } ;
134+ // using React SyntheticEvent to deal with cross browser issue
135+ this . handleHotKey = ( e : React . KeyboardEvent ) => {
123136 if ( this . state . isFocusOnInput && this . props . value . length >= 3 ) {
124137 if ( e . key === 'ArrowUp' ) {
125138 this . reduceSelectedContactIndex ( ) ;
@@ -133,7 +146,7 @@ class RecipientsInput extends Component {
133146 selectedContactIndex : 0 ,
134147 } ) ;
135148 }
136- if ( e . key === ',' || e . key === ';' || e . key === 'Enter' ) {
149+ if ( this . isSplitter ( e ) ) {
137150 e . preventDefault ( ) ;
138151 if ( this . props . value . length === 0 ) {
139152 return ;
You can’t perform that action at this time.
0 commit comments