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
Dispatch custom event when editor is ready #1134
base: master
Are you sure you want to change the base?
Conversation
Useful for e2e specs
I agree, it should be possible to actually wait for the editor to be ready with this:) |
useEffect(() => { | ||
const event = new CustomEvent('editorReady'); | ||
window.dispatchEvent(event); | ||
}, []); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually on second thought I'm not sure. I think maybe the Slate-component needs some time to initialize, and this wouldn't take that into account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it'll work 100% either, but we might as well test it out and see how it works tried researching for other options but can't seem to find many better alternatives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this doesn't work. I tested it a bit locally (by using yarn pack
to get a tar.gz
archive of the new version and then installing it using "file:<filename>" in package.json of lego-webapp). Even when I was finally able to make cypress wait for the "editorReady"-event, it still fails about 1/3 of the times when the first action is typing into the editor.
@eikhr I only get errors when I do exactly what you do for testing ... However, do you think it would help if we added |
I don't think so. The event emitter works fine and we get one event when the component is initially rendered, but it seems Slate is still not ready to accept input at this time. I think there is something internally in Slate that runs async and must be finished before it starts accepting inputs. I'm not really sure how we can detect that. |
I believe this will be useful for our e2e spec, but I haven't tested it in practice because I can't get the local package linking to work ..