Skip to content

Commit ff0c689

Browse files
committed
fix right side panel initial state
1 parent a9cb0e2 commit ff0c689

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

apps/remix-ide/src/app/components/right-side-panel.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,19 @@ export class RightSidePanel extends AbstractPanel {
3939
}
4040
})
4141

42+
// Initialize isHidden state from localStorage
4243
const rightSidePanelState = window.localStorage.getItem('rightSidePanelState')
43-
if (!rightSidePanelState) window.localStorage.setItem('rightSidePanelState', JSON.stringify({}))
44+
if (rightSidePanelState) {
45+
try {
46+
const state = JSON.parse(rightSidePanelState)
47+
this.isHidden = state.isHidden || false
48+
} catch (e) {
49+
this.isHidden = false
50+
}
51+
} else {
52+
this.isHidden = false
53+
window.localStorage.setItem('rightSidePanelState', JSON.stringify({}))
54+
}
4455
}
4556

4657
async pinView (profile, view) {
@@ -114,6 +125,14 @@ export class RightSidePanel extends AbstractPanel {
114125
this.emit('rightSidePanelHidden')
115126
this.events.emit('rightSidePanelHidden')
116127
}
128+
// Persist the hidden state to localStorage
129+
const activePlugin = this.currentFocus()
130+
if (activePlugin && this.plugins[activePlugin]) {
131+
const profile = this.plugins[activePlugin].profile
132+
window.localStorage.setItem('rightSidePanelState', JSON.stringify({ pluginProfile: profile, isHidden: this.isHidden }))
133+
}
134+
// Re-render to update the toggle icon
135+
this.renderComponent()
117136
}
118137

119138
isPanelHidden() {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ const RemixApp = (props: IRemixAppUi) => {
152152
props.app.rightSidePanel.events.on('pinnedPlugin', (profile, isHidden) => {
153153
if (!isHidden) setHidePinnedPanel(false)
154154
})
155+
156+
props.app.rightSidePanel.events.on('rightSidePanelShown', () => {
157+
setHidePinnedPanel(false)
158+
})
159+
160+
props.app.rightSidePanel.events.on('rightSidePanelHidden', () => {
161+
setHidePinnedPanel(true)
162+
})
155163
}
156164

157165
setInterval(() => {

0 commit comments

Comments
 (0)