Skip to content

Commit

Permalink
Fixed before input bug (facebook#31957)
Browse files Browse the repository at this point in the history
  • Loading branch information
HitenChawda46 committed Jan 2, 2025
1 parent c01b805 commit 85c6cbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function registerEvents() {
registerTwoPhaseEvent('onBeforeInput', [
'compositionend',
'keypress',
'textInput',
'beforeinput',
'paste',
]);
registerTwoPhaseEvent('onCompositionEnd', [
Expand Down Expand Up @@ -281,7 +281,7 @@ function getNativeBeforeInputChars(

hasSpaceKeypress = true;
return SPACEBAR_CHAR;

case 'beforeinput': // ensure that before input event is listened to
case 'textInput':
// Record the characters to be added to the DOM.
const chars = nativeEvent.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('BeforeInputEventPlugin', () => {
},
{
eventSimulator: simulateEvent,
eventSimulatorArgs: ['textInput', {data: 'abcß'}],
eventSimulatorArgs: ['beforeinput', {data: 'abcß'}],
},
{
eventSimulator: simulateKeyboardEvent,
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('BeforeInputEventPlugin', () => {
},
{
eventSimulator: simulateEvent,
eventSimulatorArgs: ['textInput', {data: '\uD83D\uDE0A'}],
eventSimulatorArgs: ['beforeinput', {data: '\uD83D\uDE0A'}],
},
{
eventSimulator: simulateKeyboardEvent,
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('BeforeInputEventPlugin', () => {
{
run: ({beforeInputEvent, spyOnBeforeInput}) => {
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
expect(beforeInputEvent.nativeEvent.type).toBe('textInput');
expect(beforeInputEvent.nativeEvent.type).toBe('beforeinput');
expect(beforeInputEvent.type).toBe('beforeinput');
expect(beforeInputEvent.data).toBe('abcß');
},
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('BeforeInputEventPlugin', () => {
{
run: ({beforeInputEvent, spyOnBeforeInput}) => {
expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);
expect(beforeInputEvent.nativeEvent.type).toBe('textInput');
expect(beforeInputEvent.nativeEvent.type).toBe('beforeinput');
expect(beforeInputEvent.type).toBe('beforeinput');
expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');
},
Expand Down

0 comments on commit 85c6cbc

Please sign in to comment.