Skip to content

Commit 5ff94d2

Browse files
committed
fix typescript error & css
1 parent e8800d6 commit 5ff94d2

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

components/dash-core-components/src/components/Tabs.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,25 @@ function Tabs({
112112
return [children];
113113
}, [children]);
114114

115-
const valueOrDefault = () => {
115+
const valueOrDefault = (): string | undefined => {
116116
if (has('value', props)) {
117117
return props.value;
118118
}
119119
const children = parseChildrenToArray();
120120
if (children && children.length && children[0].props.componentPath) {
121-
const firstChildren = window.dash_component_api.getLayout([
122-
...children[0].props.componentPath,
123-
'props',
124-
'value',
125-
]);
126-
return firstChildren || 'tab-1';
121+
const firstChildren: TabProps = window.dash_component_api.getLayout(
122+
[...children[0].props.componentPath, 'props']
123+
);
124+
return firstChildren.value;
127125
}
128-
return 'tab-1';
126+
return undefined;
129127
};
130128

131129
// Initialize value on mount if not set
132130
useEffect(() => {
133131
if (!initializedRef.current && !has('value', props)) {
134132
props.setProps({
135-
value: valueOrDefault(),
133+
value: `${valueOrDefault()}`,
136134
});
137135
initializedRef.current = true;
138136
}

components/dash-core-components/src/components/css/tabs.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
box-sizing: border-box;
2929
}
3030

31-
.tab:last-of-type {
32-
border-right: 1px solid var(--tabs-border);
33-
border-bottom: 1px solid var(--tabs-border);
34-
}
35-
3631
.tab:hover {
3732
cursor: pointer;
3833
}
@@ -65,8 +60,13 @@
6560
border-right: none;
6661
}
6762

63+
.tab-parent--above-breakpoint .tab:last-child {
64+
border-right: 1px solid var(--tabs-border);
65+
border-bottom: 1px solid var(--tabs-border);
66+
}
67+
6868
.tab-parent--above-breakpoint .tab--selected,
69-
.tab-parent--above-breakpoint .tab:last-of-type.tab--selected {
69+
.tab-parent--above-breakpoint .tab:last-child.tab--selected {
7070
border-bottom: none;
7171
}
7272

@@ -81,7 +81,7 @@
8181
.tab--selected,
8282
.tab-parent--above-breakpoint
8383
.tab-container:not(.tab-container--vert)
84-
.tab:last-of-type.tab--selected {
84+
.tab:last-child.tab--selected {
8585
border-top: 2px solid var(--tabs-primary);
8686
}
8787

@@ -91,7 +91,7 @@
9191
border-bottom: none !important;
9292
}
9393

94-
.tab-parent--above-breakpoint .tab-container--vert .tab:last-of-type {
94+
.tab-parent--above-breakpoint .tab-container--vert .tab:last-child {
9595
border-bottom: 1px solid var(--tabs-border) !important;
9696
}
9797

dash/dash-renderer/src/types/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface DashComponentApi {
1616
ExternalWrapper: typeof ExternalWrapper;
1717
DashContext: typeof DashContext;
1818
useDashContext: typeof useDashContext;
19-
getLayout: (componentPathOrId: DashLayoutPath | string) => DashComponent;
19+
getLayout: (componentPathOrId: DashLayoutPath | string) => any;
2020
stringifyId: typeof stringifyId;
2121
}
2222

0 commit comments

Comments
 (0)