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

Browser undo/redo behavior seems to be broken #110

Open
scottadamsmith opened this issue Apr 6, 2018 · 1 comment
Open

Browser undo/redo behavior seems to be broken #110

scottadamsmith opened this issue Apr 6, 2018 · 1 comment

Comments

@scottadamsmith
Copy link
Contributor

I have been digging into this quite a bit trying to find the root cause, but have had no luck so far. For a while, I still thought it might have been something about my implementation specifically, but then I noticed I could recreate the issue on one of the example jsfiddles: https://jsfiddle.net/fergal_doyle/bqys2p5y/

The behavior I am describing is in Chrome. There also seems to be issues in Firefox, but they are a bit different because Firefox doesn't support undo/redo the same Chrome does.

To recreate:

  • Type into the first
  • Tab to the next field
  • Type text in the next field
  • Then try and ctrl+z repeatedly to undo all entries.
  • If you do this repeatedly and try and redo, you can see that the undo/redo history seems to get completely messed up and it will either redo nothing or redo the wrong text

I'm very open to assisting with a fix for this, but I am struggling to identify the cause. The only thing I can think of is that perhaps the frequent watch triggers start to run out of order, but I am throwing darts at this point.

@scottadamsmith
Copy link
Contributor Author

scottadamsmith commented Apr 6, 2018

I looked into it further and I believe I have narrowed it down to the focus event listener being added here:

el.addEventListener('focus', () => {
fieldstate._setFocused(true);
}, false);

I have seen consistently that I remove that event listener, undo/redo behavior is solid, but when I replace it, the issues crop again. I am not yet clear why, but figured I'd share in case this sheds any light.

Edit: Changing the native event listener to 'focusin' as opposed to 'focus' seems to resolve the issue and still seems to work. However, I would hesitate to suggest this without a better understanding of the cause.

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

1 participant