Skip to content

Commit 5c6aff9

Browse files
authored
Merge pull request #17 from anday013/fix/focus-color-issue
fix: prevent focusColor override
2 parents dd13a1a + 93a8a2e commit 5c6aff9

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

dist/src/OtpInput/OtpInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ exports.OtpInput = (0, react_1.forwardRef)((props, ref) => {
2020
const isFocusedInput = index === focusedInputIndex;
2121
return (<react_native_1.Pressable key={`${char}-${index}`} onPress={handlePress} style={[
2222
OtpInput_styles_1.styles.codeContainer,
23-
focusColor && isFocusedInput ? { borderColor: focusColor } : {},
2423
pinCodeContainerStyle,
24+
focusColor && isFocusedInput ? { borderColor: focusColor } : {},
2525
]} testID="otp-input">
2626
{isFocusedInput && !hideStick ? (<VerticalStick_1.VerticalStick focusColor={focusColor} style={focusStickStyle} focusStickBlinkingDuration={focusStickBlinkingDuration}/>) : (<react_native_1.Text style={[OtpInput_styles_1.styles.codeText, pinCodeTextStyle]}>{char}</react_native_1.Text>)}
2727
</react_native_1.Pressable>);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-otp-entry",
3-
"version": "1.1.9",
3+
"version": "1.1.10",
44
"description": "A fully modifiable OTP input Component for React Native",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

src/OtpInput/OtpInput.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ describe("OtpInput", () => {
2222
expect(stick).toBeTruthy();
2323
});
2424

25+
test("focusColor should not be overridden by theme", () => {
26+
renderOtpInput({
27+
focusColor: "#000",
28+
theme: { pinCodeContainerStyle: { borderColor: "#fff" } },
29+
});
30+
31+
const inputs = screen.getAllByTestId("otp-input");
32+
33+
expect(inputs[0]).toHaveStyle({ borderColor: "#000" });
34+
});
35+
2536
// Test if the number of rendered inputs is equal to the number of digits
2637
test.each([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])(
2738
"should render the correct number of inputs: %i",

src/OtpInput/OtpInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
4343
onPress={handlePress}
4444
style={[
4545
styles.codeContainer,
46-
focusColor && isFocusedInput ? { borderColor: focusColor } : {},
4746
pinCodeContainerStyle,
47+
focusColor && isFocusedInput ? { borderColor: focusColor } : {},
4848
]}
4949
testID="otp-input"
5050
>

src/OtpInput/__snapshots__/OtpInput.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ exports[`OtpInput UI should render correctly 1`] = `
6464
"minHeight": 60,
6565
"minWidth": 44,
6666
},
67+
undefined,
6768
{
6869
"borderColor": "#A4D0A4",
6970
},
70-
undefined,
7171
]
7272
}
7373
testID="otp-input"
@@ -139,8 +139,8 @@ exports[`OtpInput UI should render correctly 1`] = `
139139
"minHeight": 60,
140140
"minWidth": 44,
141141
},
142-
{},
143142
undefined,
143+
{},
144144
]
145145
}
146146
testID="otp-input"
@@ -197,8 +197,8 @@ exports[`OtpInput UI should render correctly 1`] = `
197197
"minHeight": 60,
198198
"minWidth": 44,
199199
},
200-
{},
201200
undefined,
201+
{},
202202
]
203203
}
204204
testID="otp-input"
@@ -255,8 +255,8 @@ exports[`OtpInput UI should render correctly 1`] = `
255255
"minHeight": 60,
256256
"minWidth": 44,
257257
},
258-
{},
259258
undefined,
259+
{},
260260
]
261261
}
262262
testID="otp-input"
@@ -313,8 +313,8 @@ exports[`OtpInput UI should render correctly 1`] = `
313313
"minHeight": 60,
314314
"minWidth": 44,
315315
},
316-
{},
317316
undefined,
317+
{},
318318
]
319319
}
320320
testID="otp-input"
@@ -371,8 +371,8 @@ exports[`OtpInput UI should render correctly 1`] = `
371371
"minHeight": 60,
372372
"minWidth": 44,
373373
},
374-
{},
375374
undefined,
375+
{},
376376
]
377377
}
378378
testID="otp-input"

0 commit comments

Comments
 (0)