GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [react-interactions] Add onFocusWithin event to FocusWithin responder… · react/react@9169375

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-interactions/events/src/dom
    • Focus.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-interactions/events/src/dom/Focus.js‎

Copy file name to clipboardExpand all lines: packages/react-interactions/events/src/dom/Focus.js
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type FocusEventType = 'focus' | 'blur' | 'focuschange' | 'focusvisiblechange';
4949

5050
type FocusWithinProps = {
5151
disabled?: boolean,
52+
onFocusWithin?: (e: FocusEvent) => void,
5253
onBlurWithin?: (e: FocusEvent) => void,
5354
onFocusWithinChange?: boolean => void,
5455
onFocusWithinVisibleChange?: boolean => void,
@@ -57,7 +58,8 @@ type FocusWithinProps = {
5758
type FocusWithinEventType =
5859
| 'focuswithinvisiblechange'
5960
| 'focuswithinchange'
60-
| 'blurwithin';
61+
| 'blurwithin'
62+
| 'focuswithin';
6163

6264
/**
6365
* Shared between Focus and FocusWithin
@@ -239,6 +241,26 @@ function dispatchBlurEvents(
239241
}
240242
}
241243

244+
function dispatchFocusWithinEvents(
245+
context: ReactDOMResponderContext,
246+
event: ReactDOMResponderEvent,
247+
props: FocusWithinProps,
248+
state: FocusState,
249+
) {
250+
const pointerType = state.pointerType;
251+
const target = ((state.focusTarget: any): Element | Document) || event.target;
252+
const onFocusWithin = (props.onFocusWithin: any);
253+
if (isFunction(onFocusWithin)) {
254+
const syntheticEvent = createFocusEvent(
255+
context,
256+
'focuswithin',
257+
target,
258+
pointerType,
259+
);
260+
context.dispatchEvent(syntheticEvent, onFocusWithin, DiscreteEvent);
261+
}
262+
}
263+
242264
function dispatchBlurWithinEvents(
243265
context: ReactDOMResponderContext,
244266
event: ReactDOMResponderEvent,
@@ -474,6 +496,7 @@ const focusWithinResponderImpl = {
474496
state.isFocusVisible = isGlobalFocusVisible;
475497
dispatchFocusWithinVisibleChangeEvent(context, props, state, true);
476498
}
499+
dispatchFocusWithinEvents(context, event, props, state);
477500
break;
478501
}
479502
case 'blur': {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.