Skip to content
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

Add callback for startEditing #12

Closed
margual56 opened this issue Jan 22, 2021 · 2 comments
Closed

Add callback for startEditing #12

margual56 opened this issue Jan 22, 2021 · 2 comments

Comments

@margual56
Copy link
Contributor

Simply adding if (props.startEditing) { props.startEditing(); } to this line should be enough (correct me if I'm wrong).

Cool little class! :)

@margual56
Copy link
Contributor Author

margual56 commented Jan 22, 2021

Okey, I've just tried it and if you just do what I mentioned in the previous comment, it calls the event multiple times (each time you click obviously). I didn't see that coming...

Maybe a boolean that resets onBlur would fix it?

@margual56
Copy link
Contributor Author

As a temporary fix, you could add the condition !isEditMode (it works, I've tried it), so the final code would be:

const getIntoEditMode = () => {
   if (props.startEditing && !isEditMode) {
      props.startEditing();
   }
   setEditMode(true);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants