Skip to content

Commit 48a8490

Browse files
Rajat ChaudharyRajat Chaudhary
authored andcommitted
fix: invalid state for switch and select
1 parent a7e810e commit 48a8490

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

example/storybook-nativewind/src/core-components/nativewind/select/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import {
2525
} from './select-actionsheet';
2626
import { Pressable, View, TextInput, Platform } from 'react-native';
2727

28-
/** Select Components */
28+
const SelectTriggerWrapper = React.forwardRef(
29+
({ ...props }: any, ref?: any) => {
30+
return <Pressable {...props} ref={ref} />;
31+
}
32+
);
2933

3034
const selectIconStyle = tva({
3135
base: 'text-background-500 fill-none',
@@ -137,8 +141,8 @@ const UISelect = createSelect(
137141
// @ts-ignore
138142
Trigger:
139143
Platform.OS === 'web'
140-
? withStyleContext(Pressable)
141-
: withStyleContextAndStates(Pressable),
144+
? withStyleContext(SelectTriggerWrapper)
145+
: withStyleContextAndStates(SelectTriggerWrapper),
142146
Input: TextInput,
143147
Icon: PrimitiveIcon,
144148
},
@@ -162,7 +166,7 @@ cssInterop(UISelect, { className: 'style' });
162166
cssInterop(UISelect.Input, {
163167
className: { target: 'style', nativeStyleToProp: { textAlign: true } },
164168
});
165-
cssInterop(UISelect.Trigger, { className: 'style' });
169+
cssInterop(SelectTriggerWrapper, { className: 'style' });
166170
// @ts-ignore
167171
cssInterop(UISelect.Icon, {
168172
className: {

example/storybook-nativewind/src/core-components/nativewind/switch/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import { withStyleContextAndStates } from '@gluestack-ui/nativewind-utils/withSt
88
import { cssInterop } from 'nativewind';
99
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
1010

11+
const SwitchWrapper = React.forwardRef(({ ...props }: any, ref?: any) => {
12+
return <RNSwitch {...props} ref={ref} />;
13+
});
14+
1115
const UISwitch = createSwitch({
1216
Root:
1317
Platform.OS === 'web'
14-
? withStyleContext(RNSwitch)
15-
: withStyleContextAndStates(RNSwitch),
18+
? withStyleContext(SwitchWrapper)
19+
: withStyleContextAndStates(SwitchWrapper),
1620
});
1721

18-
cssInterop(UISwitch, { className: 'style' });
22+
cssInterop(SwitchWrapper, { className: 'style' });
1923

2024
const switchStyle = tva({
2125
base: 'data-[focus=true]:outline-0 data-[focus=true]:ring-2 data-[focus=true]:ring-indicator-primary web:cursor-pointer disabled:cursor-not-allowed data-[disabled=true]:opacity-40 data-[invalid=true]:border-error-700 data-[invalid=true]:rounded-xl data-[invalid=true]:border-2',

yarn.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,15 @@
26252625
"@react-native-aria/focus" "^0.2.9"
26262626
"@react-native-aria/interactions" "^0.2.11"
26272627

2628+
"@gluestack-ui/tabs@0.1.16":
2629+
version "0.1.16"
2630+
resolved "https://registry.yarnpkg.com/@gluestack-ui/tabs/-/tabs-0.1.16.tgz#54739c87d50831ed248faa0ce4015384a8f5d238"
2631+
integrity sha512-voSV4J+Ec5u9oq0cCDvgrISrVf4ObYZpbyRDJvS3L/StJYk5lM5sEfLuI3w7stlyvit9pkwi4aQKKX0BN5wBuw==
2632+
dependencies:
2633+
"@gluestack-ui/utils" "^0.1.12"
2634+
"@react-native-aria/focus" "^0.2.9"
2635+
"@react-native-aria/interactions" "0.2.13"
2636+
26282637
"@gluestack-ui/toast@^0.1.7":
26292638
version "0.1.20"
26302639
resolved "https://registry.yarnpkg.com/@gluestack-ui/toast/-/toast-0.1.20.tgz#863453f75d2e941000204a9524161bfd2500e320"

0 commit comments

Comments
 (0)