@@ -177,6 +177,7 @@ class RespAreaToolbar extends React.Component {
177177 choices : PropTypes . array ,
178178 onAddChoice : PropTypes . func . isRequired ,
179179 onCheck : PropTypes . func ,
180+ editorCallback : PropTypes . func ,
180181 onRemoveChoice : PropTypes . func . isRequired ,
181182 onSelectChoice : PropTypes . func . isRequired ,
182183 onToolbarDone : PropTypes . func . isRequired ,
@@ -283,11 +284,10 @@ class RespAreaToolbar extends React.Component {
283284
284285 onKeyDown = ( event ) => {
285286 if ( event . key === 'Enter' ) {
286- const html = event . target ?. innerHTML || '' ;
287+ const html = this . editorRef . getHTML ( ) || '' ;
287288
288289 this . onDone ( html ) ;
289290 this . preventDone = true ;
290- this . focusInput ( ) ;
291291
292292 // Cancelling event
293293 return true ;
@@ -321,16 +321,6 @@ class RespAreaToolbar extends React.Component {
321321 this . clickedInside = true ;
322322 } ;
323323
324- focusInput = ( ) => {
325- // we need to focus the input so that math is saved even without pressing the green checkmark
326- const slateEditorRef = this . editorRef && this . editorRef . rootRef && this . editorRef . rootRef . slateEditor ;
327- const inputRef = slateEditorRef && slateEditorRef . editorRef && slateEditorRef . editorRef . element ;
328-
329- if ( inputRef ) {
330- inputRef . focus ( ) ;
331- }
332- } ;
333-
334324 render ( ) {
335325 const {
336326 choices,
@@ -356,9 +346,10 @@ class RespAreaToolbar extends React.Component {
356346 >
357347 < ItemBuilder >
358348 < RespArea
359- ref = { ( ref ) => {
349+ editorRef = { ( ref ) => {
360350 if ( ref ) {
361351 this . editorRef = ref ;
352+ this . props . editorCallback ?. ( ref ) ;
362353 }
363354 } }
364355 autoFocus = { true }
@@ -407,7 +398,6 @@ class RespAreaToolbar extends React.Component {
407398 mathMlOptions = { mathMlOptions }
408399 />
409400 < AddButton
410- onMouseDown = { ( ) => this . focusInput ( ) }
411401 onClick = { ( ) => this . onAddChoice ( ) }
412402 size = "small"
413403 aria-label = "Add"
0 commit comments