Skip to content

Commit 7ea897d

Browse files
committed
Support Hidden Tabs
1 parent 04dd753 commit 7ea897d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

apps/remix-ide/src/app/panels/tab-proxy.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ export default class TabProxy extends Plugin {
186186
this.call('manager', 'deactivatePlugin', name)
187187
},
188188
icon,
189-
description
189+
description,
190+
show
190191
)
191192
show && this.switchTab(name)
192193
}
@@ -210,6 +211,7 @@ export default class TabProxy extends Plugin {
210211

211212
focus (name) {
212213
this.emit('switchApp', name)
214+
this.loadedTabs.find(tab => tab.name === name).show = true
213215
this.tabsApi.activateTab(name)
214216
}
215217

@@ -259,7 +261,7 @@ export default class TabProxy extends Plugin {
259261
* @param {string} description
260262
* @returns
261263
*/
262-
addTab (name, title, switchTo, close, icon, description = '') {
264+
addTab (name, title, switchTo, close, icon, description = '', show = true) {
263265
if (this._handlers[name]) return this.renderComponent()
264266

265267
if ((name.endsWith('.vy') && icon === undefined) || title.includes('Vyper')) {
@@ -290,7 +292,8 @@ export default class TabProxy extends Plugin {
290292
title,
291293
icon,
292294
tooltip: name,
293-
iconClass: getPathIcon(name)
295+
iconClass: getPathIcon(name),
296+
show
294297
})
295298
formatPath.shift()
296299
if (formatPath.length > 0) {
@@ -307,7 +310,8 @@ export default class TabProxy extends Plugin {
307310
title: duplicateTabTitle,
308311
icon,
309312
tooltip: duplicateTabTooltip || duplicateTabTitle,
310-
iconClass: getPathIcon(duplicateTabName)
313+
iconClass: getPathIcon(duplicateTabName),
314+
show
311315
}
312316
}
313317
}
@@ -321,7 +325,8 @@ export default class TabProxy extends Plugin {
321325
title,
322326
icon,
323327
tooltip: description || title,
324-
iconClass: getPathIcon(name)
328+
iconClass: getPathIcon(name),
329+
show
325330
})
326331
}
327332

libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface Tab {
3434
name: string
3535
title: string
3636
tooltip: string
37+
show: boolean
3738
}
3839
export interface TabsUIApi {
3940
activateTab: (name: string) => void
@@ -95,7 +96,7 @@ export const TabsUI = (props: TabsUIProps) => {
9596
const [compileState, setCompileState] = useState<'idle' | 'compiling' | 'compiled'>('idle')
9697

9798
useEffect(() => {
98-
if (props.tabs[tabsState.selectedIndex]) {
99+
if (props.tabs[tabsState.selectedIndex] && props.tabs[tabsState.selectedIndex].show) {
99100
tabsRef.current[tabsState.selectedIndex].scrollIntoView({
100101
behavior: 'smooth',
101102
block: 'center'
@@ -614,14 +615,14 @@ export const TabsUI = (props: TabsUIProps) => {
614615
>
615616
<TabList className="d-flex flex-row align-items-center">
616617
{props.tabs.map((tab, i) => (
617-
<Tab className="" key={tab.name} data-id={tab.id}>
618+
tab.show && <Tab className="" key={tab.name} data-id={tab.id}>
618619
{renderTab(tab, i)}
619620
</Tab>
620621
))}
621622
<div style={{ minWidth: '4rem', height: '1rem' }} id="dummyElForLastXVisibility"></div>
622623
</TabList>
623624
{props.tabs.map((tab) => (
624-
<TabPanel key={tab.name}></TabPanel>
625+
tab.show && <TabPanel key={tab.name}></TabPanel>
625626
))}
626627
</Tabs>
627628

0 commit comments

Comments
 (0)