Fix the issue of composition API and beforeinput event triggering between Chrome versions 60-75 on the Android platform. #5327
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We found that the code for determining the conditions of use of the
beforeinput
event is based on the following code.slate/packages/slate-react/src/utils/environment.ts
Line 36 in 96ad964
slate/packages/slate-react/src/utils/environment.ts
Line 65 in 96ad964
Where
IS_CHROME_LEGACY
determines that Chrome versions smaller than 76 cannot use thebeforeinput
event. This results in the following example of Chrome version 68 not being able to usebeforeinput
, resulting in a crash.Example
bug.mp4
Context
We know from MDN that beforeinput is supported on Android Chrome above version 60, the
IS_CHROME_LEGACY
method determines that there are some other compatibility considerations below version 76.But this set of judgments may not apply to the Android side. So we added
IS_ANDROID_CHROME_LEGACY
judgment for Android side which condition becomes greater than version 59 to use both the beforeinput event, we tested it on version 58 and 68 and it works fine.Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)