Skip to content

Commit a0e6701

Browse files
authored
Merge pull request #111 from dockersamples/keep-tab-iframes
Enable faster reload when switching tabs
2 parents 279f031 + 7b88928 commit a0e6701

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

components/interface/client/src/TabContext.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export function TabContextProvider({ children }) {
2525
const tabIndex = prevTabs.findIndex((tab) => tab.url === url);
2626
if (updatedTabs.length > 0) {
2727
const newIndex =
28-
tabIndex === 0 ? 0 : Math.min(tabIndex - 1, updatedTabs.length - 1);
28+
tabIndex === 0
29+
? 0
30+
: Math.min(tabIndex - 1, updatedTabs.length - 1);
2931
return updatedTabs[newIndex].url;
3032
} else {
3133
return null;

components/interface/client/src/components/ExternalContentPanel/ExternalContentPanel.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ export function ExternalContentPanel() {
2323
}}
2424
/>
2525
</div>
26-
{activeTab ? (
27-
<iframe
28-
ref={iframeRef}
29-
style={{ flex: 1, border: "none" }}
30-
src={activeTab}
31-
/>
26+
{tabs.length > 0 ? (
27+
<>
28+
{tabs.map((tab) => (
29+
<iframe
30+
key={tab.url}
31+
ref={tab.url === activeTab ? iframeRef : null}
32+
style={{ flex: 1, border: "none" }}
33+
src={tab.url}
34+
className={tab.url === activeTab ? "d-block" : "d-none"}
35+
/>
36+
))}
37+
</>
3238
) : (
3339
<IdePlaceholder
3440
onLaunch={() => addTab("http://localhost:8085", "Workspace")}

0 commit comments

Comments
 (0)