mirror of
https://github.com/mathuo/dockview
synced 2025-08-25 03:26:17 +00:00
bug: fix disableAutoResizing flag
This commit is contained in:
parent
d953cf9e4e
commit
126d01ede0
@ -4276,4 +4276,41 @@ describe('dockviewComponent', () => {
|
||||
expect(el).toBeTruthy();
|
||||
expect(el!.childNodes.length).toBe(0);
|
||||
});
|
||||
|
||||
test('that disableAutoResizing is false by default', () => {
|
||||
const container = document.createElement('div');
|
||||
|
||||
const dockview = new DockviewComponent({
|
||||
parentElement: container,
|
||||
components: {
|
||||
panelA: PanelContentPartTest,
|
||||
panelB: PanelContentPartTest,
|
||||
},
|
||||
tabComponents: {
|
||||
test_tab_id: PanelTabPartTest,
|
||||
},
|
||||
orientation: Orientation.HORIZONTAL,
|
||||
});
|
||||
|
||||
expect(dockview.disableResizing).toBeFalsy();
|
||||
});
|
||||
|
||||
test('that disableAutoResizing can be enabled', () => {
|
||||
const container = document.createElement('div');
|
||||
|
||||
const dockview = new DockviewComponent({
|
||||
parentElement: container,
|
||||
components: {
|
||||
panelA: PanelContentPartTest,
|
||||
panelB: PanelContentPartTest,
|
||||
},
|
||||
tabComponents: {
|
||||
test_tab_id: PanelTabPartTest,
|
||||
},
|
||||
orientation: Orientation.HORIZONTAL,
|
||||
disableAutoResizing: true,
|
||||
});
|
||||
|
||||
expect(dockview.disableResizing).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -2677,4 +2677,27 @@ describe('gridview', () => {
|
||||
expect(el).toBeTruthy();
|
||||
expect(el!.childNodes.length).toBe(0);
|
||||
});
|
||||
|
||||
test('that disableAutoResizing is false by default', () => {
|
||||
const gridview = new GridviewComponent({
|
||||
parentElement: container,
|
||||
proportionalLayout: true,
|
||||
orientation: Orientation.HORIZONTAL,
|
||||
components: { default: TestGridview },
|
||||
});
|
||||
|
||||
expect(gridview.disableResizing).toBeFalsy();
|
||||
});
|
||||
|
||||
test('that disableAutoResizing can be enabled', () => {
|
||||
const gridview = new GridviewComponent({
|
||||
parentElement: container,
|
||||
proportionalLayout: true,
|
||||
orientation: Orientation.HORIZONTAL,
|
||||
components: { default: TestGridview },
|
||||
disableAutoResizing: true,
|
||||
});
|
||||
|
||||
expect(gridview.disableResizing).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -489,4 +489,27 @@ describe('componentPaneview', () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test('that disableAutoResizing is false by default', () => {
|
||||
const paneview = new PaneviewComponent({
|
||||
parentElement: container,
|
||||
components: {
|
||||
testPanel: TestPanel,
|
||||
},
|
||||
});
|
||||
|
||||
expect(paneview.disableResizing).toBeFalsy();
|
||||
});
|
||||
|
||||
test('that disableAutoResizing can be enabled', () => {
|
||||
const paneview = new PaneviewComponent({
|
||||
parentElement: container,
|
||||
components: {
|
||||
testPanel: TestPanel,
|
||||
},
|
||||
disableAutoResizing: true,
|
||||
});
|
||||
|
||||
expect(paneview.disableResizing).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -588,4 +588,29 @@ describe('componentSplitview', () => {
|
||||
activeView: 'panel1',
|
||||
});
|
||||
});
|
||||
|
||||
test('that disableAutoResizing is false by default', () => {
|
||||
const splitview = new SplitviewComponent({
|
||||
parentElement: container,
|
||||
orientation: Orientation.VERTICAL,
|
||||
components: {
|
||||
testPanel: TestPanel,
|
||||
},
|
||||
});
|
||||
|
||||
expect(splitview.disableResizing).toBeFalsy();
|
||||
});
|
||||
|
||||
test('that disableAutoResizing can be enabled', () => {
|
||||
const splitview = new SplitviewComponent({
|
||||
parentElement: container,
|
||||
orientation: Orientation.VERTICAL,
|
||||
components: {
|
||||
testPanel: TestPanel,
|
||||
},
|
||||
disableAutoResizing: true,
|
||||
});
|
||||
|
||||
expect(splitview.disableResizing).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -305,6 +305,7 @@ export class DockviewComponent
|
||||
orientation: options.orientation ?? Orientation.HORIZONTAL,
|
||||
styles: options.styles,
|
||||
parentElement: options.parentElement,
|
||||
disableAutoResizing: options.disableAutoResizing,
|
||||
});
|
||||
|
||||
toggleClass(this.gridview.element, 'dv-dockview', true);
|
||||
|
@ -71,6 +71,7 @@ export interface DockviewDndOverlayEvent {
|
||||
}
|
||||
|
||||
export interface DockviewComponentOptions extends DockviewRenderFunctions {
|
||||
disableAutoResizing?: boolean;
|
||||
watermarkComponent?: WatermarkConstructor;
|
||||
watermarkFrameworkComponent?: any;
|
||||
frameworkComponentFactory?: GroupPanelFrameworkComponentFactory;
|
||||
|
@ -33,6 +33,7 @@ export interface BaseGridOptions {
|
||||
readonly orientation: Orientation;
|
||||
readonly styles?: ISplitviewStyles;
|
||||
readonly parentElement?: HTMLElement;
|
||||
readonly disableAutoResizing?: boolean;
|
||||
}
|
||||
|
||||
export interface IGridPanelView extends IGridView, IPanel {
|
||||
@ -128,7 +129,7 @@ export abstract class BaseGrid<T extends IGridPanelView>
|
||||
}
|
||||
|
||||
constructor(options: BaseGridOptions) {
|
||||
super(options.parentElement);
|
||||
super(options.parentElement, options.disableAutoResizing);
|
||||
|
||||
this.gridview = new Gridview(
|
||||
!!options.proportionalLayout,
|
||||
|
@ -109,6 +109,7 @@ export class GridviewComponent
|
||||
proportionalLayout: options.proportionalLayout,
|
||||
orientation: options.orientation,
|
||||
styles: options.styles,
|
||||
disableAutoResizing: options.disableAutoResizing,
|
||||
});
|
||||
|
||||
this._options = options;
|
||||
|
@ -3,6 +3,7 @@ import { ISplitviewStyles, Orientation } from '../splitview/splitview';
|
||||
import { FrameworkFactory } from '../panel/componentFactory';
|
||||
|
||||
export interface GridviewComponentOptions {
|
||||
disableAutoResizing?: boolean;
|
||||
proportionalLayout: boolean;
|
||||
orientation: Orientation;
|
||||
components?: {
|
||||
|
@ -3,6 +3,7 @@ import { PaneviewDndOverlayEvent } from './paneviewComponent';
|
||||
import { IPaneBodyPart, IPaneHeaderPart, PaneviewPanel } from './paneviewPanel';
|
||||
|
||||
export interface PaneviewComponentOptions {
|
||||
disableAutoResizing?: boolean;
|
||||
components?: {
|
||||
[componentName: string]: {
|
||||
new (id: string, componentName: string): PaneviewPanel;
|
||||
|
@ -199,7 +199,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
|
||||
}
|
||||
|
||||
constructor(options: PaneviewComponentOptions) {
|
||||
super(options.parentElement);
|
||||
super(options.parentElement, options.disableAutoResizing);
|
||||
|
||||
this.addDisposables(
|
||||
this._onDidLayoutChange,
|
||||
|
@ -3,14 +3,25 @@ import { CompositeDisposable } from './lifecycle';
|
||||
|
||||
export abstract class Resizable extends CompositeDisposable {
|
||||
private readonly _element: HTMLElement;
|
||||
private _disableResizing: boolean;
|
||||
|
||||
get element(): HTMLElement {
|
||||
return this._element;
|
||||
}
|
||||
|
||||
constructor(parentElement?: HTMLElement) {
|
||||
get disableResizing(): boolean {
|
||||
return this._disableResizing;
|
||||
}
|
||||
|
||||
set disableResizing(value: boolean) {
|
||||
this._disableResizing = value;
|
||||
}
|
||||
|
||||
constructor(parentElement?: HTMLElement, disableResizing = false) {
|
||||
super();
|
||||
|
||||
this._disableResizing = disableResizing;
|
||||
|
||||
if (parentElement) {
|
||||
this._element = parentElement;
|
||||
} else {
|
||||
@ -30,6 +41,10 @@ export abstract class Resizable extends CompositeDisposable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.disableResizing) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!document.body.contains(this._element)) {
|
||||
/**
|
||||
* since the event is dispatched through requestAnimationFrame there is a small chance
|
||||
|
@ -17,6 +17,7 @@ export interface ISerializableView extends IView, IPanel {
|
||||
}
|
||||
|
||||
export interface SplitviewComponentOptions extends SplitViewOptions {
|
||||
disableAutoResizing?: boolean;
|
||||
components?: {
|
||||
[componentName: string]: {
|
||||
new (id: string, componentName: string): SplitviewPanel;
|
||||
|
@ -158,7 +158,7 @@ export class SplitviewComponent
|
||||
}
|
||||
|
||||
constructor(options: SplitviewComponentOptions) {
|
||||
super(options.parentElement);
|
||||
super(options.parentElement, options.disableAutoResizing);
|
||||
|
||||
this._options = options;
|
||||
|
||||
|
@ -150,6 +150,7 @@ export const DockviewReact = React.forwardRef(
|
||||
parentElement: domRef.current,
|
||||
frameworkComponentFactory: factory,
|
||||
frameworkComponents: props.components,
|
||||
disableAutoResizing: props.disableAutoResizing,
|
||||
frameworkTabComponents,
|
||||
watermarkFrameworkComponent: props.watermarkComponent,
|
||||
defaultTabComponent: props.defaultTabComponent
|
||||
|
@ -47,6 +47,7 @@ export const GridviewReact = React.forwardRef(
|
||||
|
||||
const gridview = new GridviewComponent({
|
||||
parentElement: domRef.current,
|
||||
disableAutoResizing: props.disableAutoResizing,
|
||||
proportionalLayout:
|
||||
typeof props.proportionalLayout === 'boolean'
|
||||
? props.proportionalLayout
|
||||
|
@ -53,6 +53,7 @@ export const PaneviewReact = React.forwardRef(
|
||||
|
||||
const paneview = new PaneviewComponent({
|
||||
parentElement: domRef.current!,
|
||||
disableAutoResizing: props.disableAutoResizing,
|
||||
frameworkComponents: props.components,
|
||||
components: {},
|
||||
headerComponents: {},
|
||||
|
@ -41,6 +41,7 @@ export const SplitviewReact = React.forwardRef(
|
||||
React.useEffect(() => {
|
||||
const splitview = new SplitviewComponent({
|
||||
parentElement: domRef.current!,
|
||||
disableAutoResizing: props.disableAutoResizing,
|
||||
orientation: props.orientation ?? Orientation.HORIZONTAL,
|
||||
frameworkComponents: props.components,
|
||||
frameworkWrapper: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user