-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
onChange
is not called when using Cypress's type
command
#3476
Comments
@achou11 do you by any chance have a small test-case of this issue? |
There is an ongoing thread of users finding their appropriate hacks to get it working. Some may lead to a solution of how to support it natively. https://slate-js.slack.com/archives/C1RH7AXSS/p1579110773288500 |
Slate is relying more heavily on the I havent had the time to dive into this problem, but reading the documentation on cypress I noticed: https://docs.cypress.io/api/commands/type.html#Events-that-fire
And this is probably because firefox still does not declare they support https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event Firefox has released a preview version that does have https://bugzilla.mozilla.org/show_bug.cgi?id=970802 Cypress does not yet have an issue for this on their backlog as far as I could tell. https://github.com/cypress-io/cypress I'm uncertain I have enough information to make a report. |
The Cypress input commands (e.g. However, Slate relies almost exclusively on the
If you need to support other inputTypes, all of the inputTypes supported by Slate are listed here |
@reydelo Tried that approach but it didn't work. |
@alexmonteirocastro I couldn't get it to work for me either and chased it down into the source. The solution posted works and goes through all the code paths you'd want as long as your // Spec file to be ran in Cypress
describe('Test that setup works', () => {
beforeEach(function() {
cy.visit('https://www.slatejs.org/examples/richtext')
})
it('Can type in Slate using helper commands', function() {
cy.getEditor('[contenteditable=true]').typeInSlate('Some text here')
})
}) Here's a snippet from the examples on usage. |
Closing this since, as noted above, it really is a Cypress issue with Cypress not firing |
Someone was able to test the editor with CyPress without the |
Is someone knows how to simulate the enter button click in the slate input? For example, the comment input field which posts a comment after click Enter |
Do you want to request a feature or report a bug?
bug
What's the current behavior?
Using Cypress's
type
command to insert some text in a Slate editor. TheSlate
onChange
handler doesn't seem to be called while typing (note how the placeholder is never removed):Here's some console output for the
onChange
handler for the duration of this interaction:This was only logged once (presumably when the editor mounted). Instead, this should've been logged several times and the leaf should've ended up with a
text
value equivalent to what was typed.Slate: 0.57.1
Browser: Chrome (in a Cypress environment)
OS: Mac
What's the expected behavior?
onChange
should be called as the value changes when typing. There's some documentation about how events are handled for Cypress'stype
command here.The text was updated successfully, but these errors were encountered: