mirror of
https://github.com/mathuo/dockview
synced 2025-10-04 23:17:56 +00:00
fix: respect disableDnd option for tab draggable attribute
- Fix tabs and void containers to respect disableDnd option at initialization - Add dynamic update system when disableDnd option changes via updateOptions() - Ensure all tab elements properly update their draggable state when option changes - Maintains consistency with existing paneview behavior that already respects disableDnd 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9eb99f6c87
commit
ad9f884847
@ -75,7 +75,7 @@ export class Tab extends CompositeDisposable {
|
||||
this._element = document.createElement('div');
|
||||
this._element.className = 'dv-tab';
|
||||
this._element.tabIndex = 0;
|
||||
this._element.draggable = true;
|
||||
this._element.draggable = !this.accessor.options.disableDnd;
|
||||
|
||||
toggleClass(this.element, 'dv-inactive-tab', true);
|
||||
|
||||
@ -159,6 +159,10 @@ export class Tab extends CompositeDisposable {
|
||||
this._element.appendChild(this.content.element);
|
||||
}
|
||||
|
||||
public updateDragAndDropState(): void {
|
||||
this._element.draggable = !this.accessor.options.disableDnd;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
|
@ -298,4 +298,10 @@ export class Tabs extends CompositeDisposable {
|
||||
|
||||
this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
|
||||
}
|
||||
|
||||
updateDragAndDropState(): void {
|
||||
for (const tab of this._tabs) {
|
||||
tab.value.updateDragAndDropState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ export interface ITabsContainer extends IDisposable {
|
||||
setPrefixActionsElement(element: HTMLElement | undefined): void;
|
||||
show(): void;
|
||||
hide(): void;
|
||||
updateDragAndDropState(): void;
|
||||
}
|
||||
|
||||
export class TabsContainer
|
||||
@ -400,4 +401,9 @@ export class TabsContainer
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
updateDragAndDropState(): void {
|
||||
this.tabs.updateDragAndDropState();
|
||||
this.voidContainer.updateDragAndDropState();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ export class VoidContainer extends CompositeDisposable {
|
||||
this._element = document.createElement('div');
|
||||
|
||||
this._element.className = 'dv-void-container';
|
||||
this._element.draggable = true;
|
||||
this._element.draggable = !this.accessor.options.disableDnd;
|
||||
|
||||
this.addDisposables(
|
||||
this._onDrop,
|
||||
@ -79,4 +79,8 @@ export class VoidContainer extends CompositeDisposable {
|
||||
this.dropTarget
|
||||
);
|
||||
}
|
||||
|
||||
updateDragAndDropState(): void {
|
||||
this._element.draggable = !this.accessor.options.disableDnd;
|
||||
}
|
||||
}
|
||||
|
@ -1272,7 +1272,13 @@ export class DockviewComponent
|
||||
|
||||
this.updateDropTargetModel(options);
|
||||
|
||||
const oldDisableDnd = this.options.disableDnd;
|
||||
this._options = { ...this.options, ...options };
|
||||
const newDisableDnd = this.options.disableDnd;
|
||||
|
||||
if (oldDisableDnd !== newDisableDnd) {
|
||||
this.updateDragAndDropState();
|
||||
}
|
||||
|
||||
if ('theme' in options) {
|
||||
this.updateTheme();
|
||||
@ -1296,6 +1302,13 @@ export class DockviewComponent
|
||||
}
|
||||
}
|
||||
|
||||
private updateDragAndDropState(): void {
|
||||
// Update draggable state for all tabs and void containers
|
||||
for (const group of this.groups) {
|
||||
group.model.updateDragAndDropState();
|
||||
}
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
this.activeGroup?.focus();
|
||||
}
|
||||
|
@ -1136,6 +1136,10 @@ export class DockviewGroupPanelModel
|
||||
}
|
||||
}
|
||||
|
||||
updateDragAndDropState(): void {
|
||||
this.tabsContainer.updateDragAndDropState();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user