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
13 changes: 13 additions & 0 deletions packages/dockview-core/src/dockview/components/panel/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface IContentContainer extends IDisposable {
show(): void;
hide(): void;
renderPanel(panel: IDockviewPanel, options: { asActive: boolean }): void;
refreshFocusState(): void;
}

export class ContentContainer
Expand All @@ -31,6 +32,7 @@ export class ContentContainer
private readonly _element: HTMLElement;
private panel: IDockviewPanel | undefined;
private readonly disposable = new MutableDisposable();
private focusTracker: { refreshState?(): void } | undefined;

private readonly _onDidFocus = new Emitter<void>();
readonly onDidFocus: Event<void> = this._onDidFocus.event;
Expand Down Expand Up @@ -156,6 +158,7 @@ export class ContentContainer

if (doRender) {
const focusTracker = trackFocus(container);
this.focusTracker = focusTracker;
const disposable = new CompositeDisposable();

disposable.addDisposables(
Expand Down Expand Up @@ -195,4 +198,14 @@ export class ContentContainer
this.disposable.dispose();
super.dispose();
}

/**
* Refresh the focus tracker state to handle cases where focus state
* gets out of sync due to programmatic panel activation
*/
public refreshFocusState(): void {
if (this.focusTracker?.refreshState) {
this.focusTracker.refreshState();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ export class DockviewGroupPanelModel

this.updateMru(panel);

// Refresh focus state to handle programmatic activation without DOM focus change
this.contentContainer.refreshFocusState();

this._onDidActivePanelChange.fire({
panel,
});
Expand Down
Loading