Skip to content

Assess/remove state save callbacks on blur #173

@thibaudcolas

Description

@thibaudcolas

Do you want to request a feature or report a bug?

Bug. See #170 (comment). It seems that the saveState call within the editor’s onBlur is both useless, and potentially a source of headaches when managing the editor’s state.

What is the current behavior?

See #170 (comment).

I'll start with the save onBlur which actually is causing an issue for us in one specific instance. We have a form 'wizard' which has a footer container with the buttons to navigate forward and backwards. We have a sibling 'wizard content' container which has the editor. When the user has focus in the editor and immediately clicks the 'next' button, onBlur initiates the unnecessary onSave which dispatches to Redux and causes a re-render of that container. The footer container does not re-render and the click event on the button is lost.

If I comment out the this.saveState() in my node_modules version of the editor, my render problem goes away. If had the button and the editor in the same container, there is no problem either as they are rendered together but, unfortunately, I don't have any flexibility with our UX design to do that. We also have other instances of the editor where a button and editor are in the same container and they work flawlessly.

I believe that the save onBlur is really unnecessary because onSave is called after every change is processed so it seems like there should never be something new saved onBlur.

My use case for customized onBlur is whether or not to display validation results. I can validate onSave but I don't know when the user is actually "done" filling in their info.

I don't currently have a use for onFocus, but it's not hard to imagine that someone might need that for some legitimate reason.

Thanks for considering!

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. GIFs and screenshots are very helpful too.

  1. Focus the editor
  2. Enter content
  3. Move focus elsewhere
  4. Watch saveState calls

What is the expected behavior?

The saveState callback should ideally not be called multiple times with outdated content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions