@@ -58,7 +58,12 @@ import {
58
58
//renderBlock, renderMark,
59
59
} from "components/SlateJS" ;
60
60
61
- import { BrowserView , isBrowser , isMobile } from "react-device-detect" ;
61
+ import {
62
+ BrowserView ,
63
+ isBrowser ,
64
+ isMobile ,
65
+ isSafari
66
+ } from "react-device-detect" ;
62
67
import FormControl from "@material-ui/core/FormControl" ;
63
68
import Select from "@material-ui/core/Select" ;
64
69
import MenuItem from "@material-ui/core/MenuItem" ;
@@ -393,14 +398,33 @@ export class _MainComponent extends React.Component {
393
398
// this happens if the user types very quickly and it fires off a lot
394
399
// of API requests, then we keep on receiving additional messages
395
400
// from previous phrases that no longer apply
396
- if ( message . prompt . trim ( ) . slice ( - 10 ) === text . trim ( ) . slice ( - 10 ) ) {
397
- this . setState (
398
- {
399
- textPrompts : textPrompts
400
- } ,
401
- this . focusTextInput
402
- ) ;
401
+ const properMessage =
402
+ message . prompt . trim ( ) . slice ( - 10 ) === text . trim ( ) . slice ( - 10 ) ;
403
+ if ( ! properMessage ) {
404
+ return ;
403
405
}
406
+
407
+ this . setState ( {
408
+ textPrompts : textPrompts
409
+ } ) ;
410
+
411
+ // safari has an issue with slatejs race condition where focus is called
412
+ // before the message has been fully loaded as slatejs text state
413
+ //if (isSafari) {
414
+ // this.setState(
415
+ // {
416
+ // textPrompts: textPrompts
417
+ // },
418
+ // );
419
+ //}
420
+ //else {
421
+ // this.setState(
422
+ // {
423
+ // textPrompts: textPrompts
424
+ // },
425
+ // this.focusTextInput
426
+ // );
427
+ //}
404
428
} ;
405
429
406
430
webSocketConnected = ( ) => {
0 commit comments