1

I am trying to integrate the slate js editor here in my app and have successfully done that. Every is working fine . However, i noticed my state or value doesn't get set on mobile and smaller devices. Upon investigation and debugging, i realised the onChange event doesn't fire on mobile and smaller devices until i click the enter key. My state or value get updated only when i click enter key, otherwise whatever text i entered doesn't trigger the onChange event. I confirmed that onInput event does get fired, however, it doesn't expose the value within the event. Please is there any way to circumvent this issue on mobile ? What is stopping onChange event from triggering on smaller devices and how do i fix this pls ?

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116
  • The `onChange` event occurs when an element loses focus or the enter key is pressed, given that the value has been altered. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event – Matthew Sep 28 '19 at 07:34
  • @Matthew yes, i understand that. But without that i can't update my text, i am searching for alternative on slate js. I have been trying to utilised the onIput event to no avail. – Nuru Salihu Sep 28 '19 at 07:36
  • `onchange` is case sensitive. – Ali Sheikhpour Sep 28 '19 at 07:36
  • 1
    @NuruSalihu maybe try looking into `onKeyup` or `onBlur` as another fix? – Matthew Sep 28 '19 at 07:37
  • I was thinking, why not hack it in a way to automatically press the enter key for someone? So an event that would fire after 2 seconds to see if they haven’t typed and if there has been no modification s and that the user is there focused on that, it’ll just press enter on behalf of the user. Does that sound like a possible solution? I know it may not be what you want, but maybe be a fix for your mobile issue. – Matthew Sep 28 '19 at 16:36

0 Answers0