Skip to content

Commit ecd3159

Browse files
dmnplbLeleDallas
andauthored
fix: [IOPLT-997] Fix visual issue on dark mode version of TabItem (#420)
## Short description This PR fixes a visual issue that was present in the dark mode version of the `TabItem` component. ## List of changes proposed in this pull request - Remove the `useAnimatedStyle` dependency in the `TabItem` component, which was probably causing the buggy behavior - Remove the `fullWidth` prop because it was never referenced or officially supported - Slightly refactor `TabNavigation` to replace old logic with the new `gap` property ### Preview > [!note] > Please note the border of the selected state, before and after | Before | After | |--------|--------| | <video src="https://github.com/user-attachments/assets/b80b0bbd-2c6f-4d90-9119-6f80faea814f" /> | <video src="https://github.com/user-attachments/assets/ed061deb-7b13-4ed5-ac44-0bdfbac87585" /> | ## How to test There's no easy way to replicate the buggy behavior in the example app included in this repo. But you can test the behavior in the `io-app` repo by updating the `"@pagopa/io-app-design-system"` field in the `package.json` with the PR `https` url of this PR: ```json "@pagopa/io-app-design-system": "https://github.com/pagopa/io-app-design-system#IOPLT-997-fix-visual-issue-tabitem-darkmode" ``` Co-authored-by: Emanuele Dall'Ara <[email protected]>
1 parent c89e394 commit ecd3159

File tree

2 files changed

+20
-31
lines changed

2 files changed

+20
-31
lines changed

src/components/tabs/TabItem.tsx

+18-27
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export type TabItem = WithTestID<{
3333
label: string;
3434
color?: ColorMode;
3535
selected?: boolean;
36-
fullWidth?: boolean;
3736
// Icons
3837
icon?: IOIcons;
3938
iconSelected?: IOIcons;
@@ -69,7 +68,6 @@ const TabItem = forwardRef(
6968
label,
7069
color = "light",
7170
selected = false,
72-
fullWidth = false,
7371
accessibilityLabel,
7472
accessibilityHint,
7573
testID,
@@ -149,27 +147,24 @@ const TabItem = forwardRef(
149147
);
150148

151149
// Interpolate animation values from `pressed` values
152-
const animatedStyle = useAnimatedStyle(
153-
() => ({
154-
backgroundColor: interpolateColor(
155-
selectedStateTransition.value,
156-
[0, 1],
157-
[
158-
mapColorStates[color].background.default,
159-
mapColorStates[color].background.selected
160-
]
161-
),
162-
borderColor: interpolateColor(
163-
selectedStateTransition.value,
164-
[0, 1],
165-
[
166-
mapColorStates[color].border.default,
167-
mapColorStates[color].border.selected
168-
]
169-
)
170-
}),
171-
[selectedStateTransition]
172-
);
150+
const animatedStyle = useAnimatedStyle(() => ({
151+
backgroundColor: interpolateColor(
152+
selectedStateTransition.value,
153+
[0, 1],
154+
[
155+
mapColorStates[color].background.default,
156+
mapColorStates[color].background.selected
157+
]
158+
),
159+
borderColor: interpolateColor(
160+
selectedStateTransition.value,
161+
[0, 1],
162+
[
163+
mapColorStates[color].border.default,
164+
mapColorStates[color].border.selected
165+
]
166+
)
167+
}));
173168

174169
const activeIcon = selected ? iconSelected ?? icon : icon;
175170

@@ -203,7 +198,6 @@ const TabItem = forwardRef(
203198
{ columnGap: 4 },
204199
!disabled && !reducedMotion && scaleAnimatedStyle,
205200
animatedStyle,
206-
fullWidth && styles.fullWidth,
207201
disabled && { opacity: DISABLED_OPACITY }
208202
]}
209203
>
@@ -235,9 +229,6 @@ const styles = StyleSheet.create({
235229
borderCurve: "continuous",
236230
justifyContent: "center",
237231
alignSelf: "flex-start"
238-
},
239-
fullWidth: {
240-
alignSelf: "auto"
241232
}
242233
});
243234

src/components/tabs/TabNavigation.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ const TabNavigation = ({
5656
key={index}
5757
style={[
5858
styles.item,
59-
{
60-
marginEnd: index === React.Children.count(children) - 1 ? 0 : 8
61-
},
6259
stretchItems && {
6360
minWidth: itemMinWidth
6461
}
@@ -87,7 +84,8 @@ const TabNavigation = ({
8784
: {},
8885
{
8986
flexGrow: 1,
90-
justifyContent: itemsJustify[tabAlignment]
87+
justifyContent: itemsJustify[tabAlignment],
88+
gap: 8
9189
}
9290
]}
9391
>

0 commit comments

Comments
 (0)