New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assess/remove state save callbacks on blur #173

Closed
thibaudcolas opened this Issue Dec 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@thibaudcolas
Copy link
Collaborator

thibaudcolas commented Dec 10, 2018

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.

@thibaudcolas thibaudcolas added the bug label Dec 10, 2018

@thibaudcolas thibaudcolas added this to the v1.1.0 milestone Dec 10, 2018

thibaudcolas added a commit that referenced this issue Jan 2, 2019

thibaudcolas added a commit that referenced this issue Jan 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment