From 7c3d00bbd0c41373dcba71c0f7ead049619c55c0 Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Thu, 22 May 2025 11:32:19 -0400 Subject: [PATCH 1/3] Add support for TargetEvent type in focus, blur callbacks Summary: The documentation for `onBlur` and `onFocus` events either omits the native event type or incorrectly points to `LayoutEvent` as the event type. This should fix the issue --- docs/layoutevent.md | 2 +- docs/targetevent.md | 29 +++++++++++++++++++++++++++++ docs/textinput.md | 8 ++++---- docs/touchablewithoutfeedback.md | 12 ++++++------ website/sidebars.ts | 1 + 5 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 docs/targetevent.md diff --git a/docs/layoutevent.md b/docs/layoutevent.md index b0fda8501db..1c4464bbef1 100644 --- a/docs/layoutevent.md +++ b/docs/layoutevent.md @@ -55,7 +55,7 @@ Component Y coordinate inside the parent component. ### `target` -The node id of the element receiving the PressEvent. +The node id of the element receiving the LayoutEvent. | Type | Optional | | --------------------------- | -------- | diff --git a/docs/targetevent.md b/docs/targetevent.md new file mode 100644 index 00000000000..d5ad583c9bf --- /dev/null +++ b/docs/targetevent.md @@ -0,0 +1,29 @@ +--- +id: targetevent +title: TargetEvent Object Type +--- + +`TargetEvent` object is returned in the callback as a result of focus change, for example `onFocus` or `onBlur` in the [TextInput](textinput) component. + +## Example + +```js +{ + target: 1127 +} +``` + +## Keys and values + +### `target` + +The node id of the element receiving the TargetEvent. + +| Type | Optional | +| --------------------------- | -------- | +| number, `null`, `undefined` | No | + +## Used by + +- [`TextInput`](textinput) +- [`TouchableWithoutFeedback`](touchablewithoutfeedback) diff --git a/docs/textinput.md b/docs/textinput.md index 95963b98f16..d26f8772e7c 100644 --- a/docs/textinput.md +++ b/docs/textinput.md @@ -565,9 +565,9 @@ Callback that is called when the text input is blurred. > Note: If you are attempting to access the `text` value from `nativeEvent` keep in mind that the resulting value you get can be `undefined` which can cause unintended errors. If you are trying to find the last value of TextInput, you can use the [`onEndEditing`](textinput#onendediting) event, which is fired upon completion of editing. -| Type | -| -------- | -| function | +| Type | +| -------------------------------------------------------- | +| `md ({nativeEvent: [TargetEvent](targetevent)}) => void` | --- @@ -639,7 +639,7 @@ Callback that is called when the text input is focused. | Type | | -------------------------------------------------------- | -| `md ({nativeEvent: [LayoutEvent](layoutevent)}) => void` | +| `md ({nativeEvent: [TargetEvent](targetevent)}) => void` | --- diff --git a/docs/touchablewithoutfeedback.md b/docs/touchablewithoutfeedback.md index 1096aa7c695..f80cb4a0a03 100644 --- a/docs/touchablewithoutfeedback.md +++ b/docs/touchablewithoutfeedback.md @@ -424,9 +424,9 @@ Used to locate this view from native code. Has precedence over `nativeID` prop. Invoked when the item loses focus. -| Type | -| -------- | -| function | +| Type | +| -------------------------------------------------------- | +| `md ({nativeEvent: [TargetEvent](targetevent)}) => void` | --- @@ -434,9 +434,9 @@ Invoked when the item loses focus. Invoked when the item receives focus. -| Type | -| -------- | -| function | +| Type | +| -------------------------------------------------------- | +| `md ({nativeEvent: [TargetEvent](targetevent)}) => void` | --- diff --git a/website/sidebars.ts b/website/sidebars.ts index 88c39837eb0..89c7934702a 100644 --- a/website/sidebars.ts +++ b/website/sidebars.ts @@ -299,6 +299,7 @@ export default { 'pressevent', 'react-node', 'rect', + 'targetevent', 'viewtoken', ], }, From f802d24e8926188e7cbc058740b0653be646831f Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Thu, 22 May 2025 11:32:19 -0400 Subject: [PATCH 2/3] Add support for TargetEvent type in focus, blur callbacks Summary: The documentation for `onBlur` and `onFocus` events either omits the native event type or incorrectly points to `LayoutEvent` as the event type. This should fix the issue --- docs/targetevent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/targetevent.md b/docs/targetevent.md index d5ad583c9bf..ffa4f6aa2b8 100644 --- a/docs/targetevent.md +++ b/docs/targetevent.md @@ -7,7 +7,7 @@ title: TargetEvent Object Type ## Example -```js +``` { target: 1127 } From 844166668d68b3b3605c5e874a5d446149e67d5a Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Thu, 22 May 2025 11:51:20 -0400 Subject: [PATCH 3/3] Remove targetevent from sidebar links until it lands --- website/sidebars.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/website/sidebars.ts b/website/sidebars.ts index 89c7934702a..88c39837eb0 100644 --- a/website/sidebars.ts +++ b/website/sidebars.ts @@ -299,7 +299,6 @@ export default { 'pressevent', 'react-node', 'rect', - 'targetevent', 'viewtoken', ], },