Skip to content

Commit

Permalink
fix: onFocus/onBlur have a matching event type
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Aug 8, 2020
1 parent 0334244 commit b6856b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('SyntheticFocusEvent', () => {
}),
);

expect(log).toEqual(['onFocusCapture: focusin', 'onFocus: focusin']);
expect(log).toEqual(['onFocusCapture: focus', 'onFocus: focus']);
});

test('onBlur events have the blur type', () => {
Expand All @@ -65,6 +65,6 @@ describe('SyntheticFocusEvent', () => {
}),
);

expect(log).toEqual(['onBlurCapture: focusout', 'onBlur: focusout']);
expect(log).toEqual(['onBlurCapture: blur', 'onBlur: blur']);
});
});
7 changes: 7 additions & 0 deletions packages/react-dom/src/events/plugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ function extractEvents(
EventInterface,
);

if (domEventName === 'focusin') {
event.type = 'focus';
}
if (domEventName === 'focusout') {
event.type = 'blur';
}

const inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
if (
enableCreateEventHandleAPI &&
Expand Down

0 comments on commit b6856b2

Please sign in to comment.