Skip to content

Commit

Permalink
fix: don't compare native event types with react event types
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Aug 8, 2020
1 parent 0e98446 commit cc2ae0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/DOMPluginEventSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ export function accumulateSinglePhaseListeners(

let instance = targetFiber;
let lastHostComponent = null;
const targetType = event.type;
const targetType = event.nativeEvent.type;

// Accumulate all instances and listeners via the target -> root path.
while (instance !== null) {
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/events/ReactSyntheticEventType.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type ReactSyntheticEvent = {|
_dispatchListeners?: null | Array<Function> | Function,
_reactName: string,
_targetInst: Fiber,
nativeEvent: Event,
type: string,
currentTarget: null | EventTarget,
|};
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ export function useFocus(
const stateRef = useRef<null | {isFocused: boolean, isFocusVisible: boolean}>(
{isFocused: false, isFocusVisible: false},
);
const focusHandle = useEvent('focus', passiveObjectWithPriority);
const blurHandle = useEvent('blur', passiveObjectWithPriority);
const focusHandle = useEvent('focusin', passiveObjectWithPriority);
const blurHandle = useEvent('focusout', passiveObjectWithPriority);
const focusVisibleHandles = useFocusVisibleInputHandles();

useLayoutEffect(() => {
Expand Down Expand Up @@ -297,8 +297,8 @@ export function useFocusWithin<T>(
const stateRef = useRef<null | {isFocused: boolean, isFocusVisible: boolean}>(
{isFocused: false, isFocusVisible: false},
);
const focusHandle = useEvent('focus', passiveObjectWithPriority);
const blurHandle = useEvent('blur', passiveObjectWithPriority);
const focusHandle = useEvent('focusin', passiveObjectWithPriority);
const blurHandle = useEvent('focusout', passiveObjectWithPriority);
const afterBlurHandle = useEvent('afterblur', passiveObject);
const beforeBlurHandle = useEvent('beforeblur', passiveObject);
const focusVisibleHandles = useFocusVisibleInputHandles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
useFocus(ref, {
onBlur,
});
return <div ref={ref} onBlur={() => {}} onFocus={() => {}} />;
return <div ref={ref} />;
};
ReactDOM.render(<Component />, container);
Scheduler.unstable_flushAll();
Expand Down Expand Up @@ -119,7 +119,7 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
onFocus,
});
return (
<div ref={ref} onFocus={() => {}}>
<div ref={ref}>
<a ref={innerRef} />
</div>
);
Expand Down Expand Up @@ -158,7 +158,7 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
});
return (
<div ref={ref}>
<div ref={innerRef} onBlur={() => {}} onFocus={() => {}} />
<div ref={innerRef} />
</div>
);
};
Expand Down Expand Up @@ -201,7 +201,7 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
onFocusVisibleChange,
});
return (
<div ref={ref} onBlur={() => {}} onFocus={() => {}}>
<div ref={ref}>
<div ref={innerRef} />
</div>
);
Expand Down Expand Up @@ -295,7 +295,7 @@ describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => {
onFocusChange: createEventHandler('outer: onFocusChange'),
});
return (
<div ref={outerRef} onBlur={() => {}} onFocus={() => {}}>
<div ref={outerRef}>
<Inner />
</div>
);
Expand Down

0 comments on commit cc2ae0c

Please sign in to comment.