Skip to content

Commit 4763843

Browse files
Merge pull request #96 from linked-planet/dev
tabs - fixed height layouting in panels
2 parents e56ec62 + 8388d6c commit 4763843

File tree

4 files changed

+73
-58
lines changed

4 files changed

+73
-58
lines changed

library/src/components/Tabs.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export type TabListProps = {
102102
style?: React.CSSProperties
103103
testId?: string
104104
side?: TabsSide
105+
allowNonTabComponents?: boolean
105106
}
106107

107108
const tabListTopClassName =
@@ -118,7 +119,15 @@ const tabListBottomClassName =
118119
*/
119120
const TabList = forwardRef(
120121
(
121-
{ children, className, style, testId, side = "top", id }: TabListProps,
122+
{
123+
children,
124+
className,
125+
style,
126+
testId,
127+
side = "top",
128+
id,
129+
allowNonTabComponents,
130+
}: TabListProps,
122131
ref: ForwardedRef<HTMLDivElement>,
123132
) => {
124133
const tabListChildrenWithValue = React.Children.map(
@@ -129,10 +138,11 @@ const TabList = forwardRef(
129138
"TabList children must be valid React elements",
130139
)
131140
}
132-
if (child.type !== Tab) {
133-
console.log(
141+
if (child.type !== Tab && !allowNonTabComponents) {
142+
console.warn(
134143
"Only Tab components are allowed as children of TabList, but was",
135144
child.type,
145+
"(use allowNonTabComponents prop to allow other components)",
136146
)
137147
}
138148
const childTyped = child as React.ReactElement<
@@ -201,7 +211,10 @@ const TabPanel = forwardRef(
201211
return (
202212
<RTabs.Content
203213
id={id}
204-
className={twMerge("data-[state=inactive]:hidden", className)}
214+
className={twMerge(
215+
"data-[state=inactive]:hidden size-full",
216+
className,
217+
)}
205218
style={style}
206219
value={label.toString()} /* this is set in the Tabs component! */
207220
data-testid={testId}
@@ -214,7 +227,8 @@ const TabPanel = forwardRef(
214227
)
215228

216229
/**
217-
* Container containing the TabList tab menu bar, and Tab panels
230+
* Container containing the TabList tab menu bar, and Tab panels.
231+
* For the TabPanels to use the correct height in case that the tab panel should have a height of 100% of the parent container, enable the heightHelper prop
218232
*/
219233
const Container = forwardRef(
220234
(
@@ -293,7 +307,7 @@ const Container = forwardRef(
293307
value={selected != null ? selected.toString() : undefined}
294308
defaultValue={defaultSelectedValue}
295309
className={twMerge(
296-
`flex p-2 ${side === "top" || side === "bottom" ? "flex-col" : ""}`,
310+
`flex p-2 size-full ${side === "top" || side === "bottom" ? "flex-col" : ""}`,
297311
className,
298312
)}
299313
style={style}

package-lock.json

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,25 @@
106106
"react-intl": "^6.8.9",
107107
"react-joyride": "^2.9.3",
108108
"react-router-dom": "^6.28.0",
109-
"react-select": "^5.8.3",
109+
"react-select": "^5.9.0",
110110
"react-syntax-highlighter": "^15.6.1",
111111
"react-toastify": "^10.0.6",
112112
"react-transition-group": "^4.4.5",
113113
"use-resize-observer": "^9.1.0"
114114
},
115115
"devDependencies": {
116116
"@atlaskit/atlassian-navigation": "^4.9.5",
117-
"@atlaskit/code": "^15.6.7",
117+
"@atlaskit/code": "^15.6.8",
118118
"@atlaskit/css-reset": "^6.11.2",
119119
"@atlaskit/lozenge": "^11.12.3",
120120
"@atlaskit/pagination": "^14.10.1",
121-
"@atlaskit/side-navigation": "^3.6.5",
121+
"@atlaskit/side-navigation": "^3.6.6",
122122
"@atlaskit/table-tree": "^10.0.7",
123123
"@atlaskit/tag": "^12.6.7",
124124
"@atlaskit/tag-group": "^11.0.0",
125125
"@atlaskit/textarea": "^5.7.0",
126126
"@atlaskit/textfield": "^6.7.0",
127-
"@atlaskit/theme": "^14.0.2",
127+
"@atlaskit/theme": "^14.0.3",
128128
"@babel/generator": "^7.26.3",
129129
"@babel/parser": "^7.26.3",
130130
"@babel/traverse": "^7.26.4",

showcase/src/components/showcase/wrapper/TabsShowcase.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react"
1+
import { useState } from "react"
22
import ShowcaseWrapperItem, {
33
type ShowcaseProps,
44
} from "../../ShowCaseWrapperItem/ShowcaseWrapperItem"
@@ -14,10 +14,11 @@ function AutomaticTabsValue() {
1414
//#region tabs_automatic_value
1515
return (
1616
<Tabs.Container>
17-
<Tabs.TabList>
17+
<Tabs.TabList allowNonTabComponents>
1818
<Tabs.Tab>Tab 1</Tabs.Tab>
1919
<Tabs.Tab>Tab 2</Tabs.Tab>
2020
<Tabs.Tab disabled>Tab 3</Tabs.Tab>
21+
<div>Other Component</div>
2122
</Tabs.TabList>
2223
<Tabs.TabPanel>
2324
<span>First Content</span>

0 commit comments

Comments
 (0)