Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Fix handleBeforeInput not working problem when typing in IME #821

Closed

Conversation

bowbowbow
Copy link

Summary

handleBeforeInput, one of Editor's props, doesn't work when typing in IME like Japanese and korean.

Related Issues

  1. handleBeforeInput is not trigger when input using an IME handleBeforeInput is not trigger when input using an IME #819
  2. How to detect unicode input event? How to detect unicode input event? #693
  3. HandleBeforeInput doesn't work when typing in Japanese. HandleBeforeInput doesn't work when typing in Japanese. #631

The cause of this problem is that this.props.handleBeforeInput is used in edit mode but it is not used in composite mode.

More specifically, editOnBeforeInput(onBeforeInput handler) in /src/handler/edit/editOnBeforeInput.js use this.props.handleBeforeInput, but onBeforeInput in /src/handler/composition/DraftEditorCompositionHandler.js doesn't use it.

I solved this problem by adding the edit mode logic to the composite mode.

close #819, #631

Test Plan

  • Add handelBeforeInput to Editor's props of example.
_handleBeforeInput(chars) {
  console.log(':: handleBeforeInput :: ', chars);
  return false; // or return true;
}
  • Typing Korean and Japanese.
  • Check handleBeforeInput working correctly

@flarnie
Copy link
Contributor

flarnie commented Apr 4, 2017

Hi @bowbowbow! Thanks for submitting this. I think the general idea is good, and I'm wondering if we should have a different handler than handleBeforeInput. The intention is to let users hook into the firing of the beforeInput event when it fires, and the problem is that it does not fire when typing in composition mode.

This is just an idea off the top of my head - would it help to add a handler for the compositionUpdate event? It seems like folks want to hook into the moment that a new character is entered by the IME, and we only get the data about that from the compositionUpdate event.

This debugging tool is a good way to verify what events get fired - https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html

screen shot 2017-04-04 at 7 10 08 am

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

Successfully merging this pull request may close these issues.

handleBeforeInput is not trigger when input using an IME
3 participants