Skip to content

Commit 5a0798a

Browse files
committed
Add nop and focus callback.
1 parent adec244 commit 5a0798a

File tree

62 files changed

+580
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+580
-14
lines changed

index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export { HorizontallySymmetricalSafeAreaView } from './react-native/components/H
6363
export { intercalateRendered } from './react-native/utilities/intercalateRendered'
6464
export { isRenderedByReact } from './react-native/utilities/isRenderedByReact'
6565
export { logger } from './react-native/services/logger'
66+
export { nop } from './react-native/utilities/nop'
6667
export { PermissionHelper } from './react-native/services/PermissionHelper'
6768
export { PictureHelper } from './react-native/services/PictureHelper'
6869
export { Request } from './react-native/services/Request'

react-native/components/createCreatableSelectComponent/createCreatableSelectChildrenComponent/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import type { ControlStyle } from '../../../types/ControlStyle'
1111
import { createInputComponent } from '../../createInputComponent'
1212
import { Hitbox } from '../../Hitbox'
13+
import { nop } from '../../../utilities/nop'
1314

1415
type Instance<T extends null | boolean | number | string> = React.FunctionComponent<{
1516
readonly options: ReadonlyArray<{
@@ -203,6 +204,7 @@ export const createCreatableSelectChildrenComponent = <
203204
setFilter(parsed)
204205
}
205206
}}
207+
onFocus={nop}
206208
secureTextEntry={false}
207209
disabled={false}
208210
placeholder={

react-native/components/createCreatableSelectComponent/createCreatableSelectChildrenComponent/unit.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { createCreatableSelectChildrenComponent } from '.'
1111
import {
1212
type ControlStyle,
1313
Hitbox,
14-
unwrapRenderedFunctionComponent
14+
unwrapRenderedFunctionComponent,
15+
nop
1516
} from '../../../..'
1617

1718
type TestValue = 10 | 20 | 30 | 40
@@ -170,6 +171,7 @@ test('renders as expected with an absent selected value', () => {
170171
rightIcon: null,
171172
value: '',
172173
onChange: expect.any(Function),
174+
onFocus: nop,
173175
secureTextEntry: false,
174176
disabled: false,
175177
autoFocus: true,
@@ -487,6 +489,7 @@ test('renders as expected with a present selected value', () => {
487489
rightIcon: null,
488490
value: '',
489491
onChange: expect.any(Function),
492+
onFocus: nop,
490493
secureTextEntry: false,
491494
disabled: false,
492495
autoFocus: true,
@@ -829,6 +832,7 @@ test('renders as expected when exact matches are found for user input', async ()
829832
rightIcon: null,
830833
value: ' EXamPLE \n OPTION \n \t \r ReD \n \n \r \t APPle \t \n \r C label \n\n \r \t ',
831834
onChange: expect.any(Function),
835+
onFocus: nop,
832836
secureTextEntry: false,
833837
disabled: false,
834838
autoFocus: true,
@@ -1027,6 +1031,7 @@ test('renders as expected when partial matches are found for user input', async
10271031
rightIcon: null,
10281032
value: ' \n \t \r ReD \n \n \r \t APPle \t \n \r',
10291033
onChange: expect.any(Function),
1034+
onFocus: nop,
10301035
secureTextEntry: false,
10311036
disabled: false,
10321037
autoFocus: true,
@@ -1216,6 +1221,7 @@ test('renders as expected when matches are not found for user input', async () =
12161221
rightIcon: null,
12171222
value: ' \n \t \r GReeN \n \n \r \t APPle \t \n \r',
12181223
onChange: expect.any(Function),
1224+
onFocus: nop,
12191225
secureTextEntry: false,
12201226
disabled: false,
12211227
autoFocus: true,
@@ -2056,6 +2062,7 @@ test('renders as expected when horizontal padding is not present', async () => {
20562062
rightIcon: null,
20572063
value: ' \n \t \r ReD \n \n \r \t APPle \t \n \r',
20582064
onChange: expect.any(Function),
2065+
onFocus: nop,
20592066
secureTextEntry: false,
20602067
disabled: false,
20612068
autoFocus: true,
@@ -2251,6 +2258,7 @@ test('renders as expected when vertical padding is not present', async () => {
22512258
rightIcon: null,
22522259
value: ' \n \t \r ReD \n \n \r \t APPle \t \n \r',
22532260
onChange: expect.any(Function),
2261+
onFocus: nop,
22542262
secureTextEntry: false,
22552263
disabled: false,
22562264
autoFocus: true,

react-native/components/createInputComponent/index.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ type Instance<TValue, TContext> = React.FunctionComponent<{
3232
*/
3333
onChange: (parsed: undefined | TValue, complete: boolean) => void
3434

35+
/**
36+
* Invoked when the user focuses the box.
37+
*/
38+
onFocus: () => void
39+
3540
/**
3641
* When true, the text value is starred out rather than being rendered (for
3742
* password fields).
@@ -393,6 +398,7 @@ export function createInputComponent<TValue, TContext> (
393398
rightIcon,
394399
value,
395400
onChange,
401+
onFocus,
396402
secureTextEntry,
397403
disabled,
398404
autoFocus,
@@ -555,6 +561,7 @@ export function createInputComponent<TValue, TContext> (
555561
onFocus={() => {
556562
focused.current = true
557563
refresh()
564+
onFocus()
558565
}}
559566
onBlur={() => {
560567
focused.current = false

react-native/components/createInputComponent/readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const ExampleScreen = () => {
116116
onSubmit={(value) => {
117117
setSubmittedValue(value);
118118
}}
119+
onFocus={() => {}}
119120
secureTextEntry={false}
120121
disabled={false}
121122
autoFocus={false}

0 commit comments

Comments
 (0)