Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/tabs/tab-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ const TabBar = (props: TabBarProps) => {
{tabList.map((child: any, i) => {
const className = child.tabComponent.props.className;
const activeClassName = child.tabComponent.props.classNameActive;
const closeableTab = child.tabComponent.props.closeable
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use defaultProps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just missed it, definitely good to put it, in this case specifically, the props are inside the child component not on the parent itself, I defined the variables here for more readability when using it on the jsx after

const { closeable } = props;
const shouldClose = closeableTab !== undefined ? (closeableTab && closeable) : closeable;
return (
<li
id={child.id}
Expand All @@ -232,7 +235,7 @@ const TabBar = (props: TabBarProps) => {
onMouseUp={closeDragElement}
>
{child.tabComponent.props.tabHeader || child.tabComponent.props.text}
{props.closeable &&
{ shouldClose &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

<span
className="close"
onClick={e => removeTab(child.id, e, child)}>
Expand Down
1 change: 1 addition & 0 deletions src/components/tabs/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface TabProps {
text?: string;
className?: string;
classNameActive?: string;
closeable?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add default props

}

const Tab = (props: TabProps) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/testInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TabInterface = () => {
newTab={createNew}
className="small-tab"
>
<Tab text="first tab" classNameActive="red-header" className="the-rest">
<Tab text="first tab" closeable={false}>
<form className="frm">
<h1>Form 1</h1>
<p>Name</p>
Expand All @@ -31,7 +31,7 @@ const TabInterface = () => {
</form>
</Tab>

<Tab text="second tab" className="the-rest">
<Tab text="second tab" >
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

<form className="frm">
<h1>Form 2</h1>
<p>Name</p>
Expand Down