Skip to content

Commit

Permalink
bug: duplicate container HTML Element
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Jan 10, 2025
1 parent 872ec7c commit b3873a2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ class ClassUnderTest extends BaseGrid<TestPanel> {
}

describe('baseComponentGridview', () => {
test('aa', () => {
const root = document.createElement('div');
const container = document.createElement('div');
root.appendChild(container);

const cut = new ClassUnderTest(container, {
orientation: Orientation.HORIZONTAL,
proportionalLayout: true,
});

cut.dispose();

expect(container.parentElement).toBe(root);
});

test('that .layout(...) force flag works', () => {
const cut = new ClassUnderTest(document.createElement('div'), {
orientation: Orientation.HORIZONTAL,
Expand Down
4 changes: 3 additions & 1 deletion packages/dockview-core/src/gridview/baseComponentGridview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ export abstract class BaseGrid<T extends IGridPanelView>
}

constructor(parentElement: HTMLElement, options: BaseGridOptions) {
super(parentElement, options.disableAutoResizing);
super(document.createElement('div'), options.disableAutoResizing);
this.element.style.height = '100%';
this.element.style.width = '100%';

this._classNames = new Classnames(this.element);
this._classNames.setClassNames(options.className ?? '');

parentElement.appendChild(this.element);

this.gridview = new Gridview(
!!options.proportionalLayout,
options.styles,
Expand Down
6 changes: 1 addition & 5 deletions packages/dockview/src/dockview/dockview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,7 @@ export const DockviewReact = React.forwardRef(
}, [props.prefixHeaderActionsComponent]);

return (
<div
className={props.className}
style={{ height: '100%', width: '100%' }}
ref={domRef}
>
<div style={{ height: '100%', width: '100%' }} ref={domRef}>
{portals}
</div>
);
Expand Down
6 changes: 1 addition & 5 deletions packages/dockview/src/gridview/gridview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ export const GridviewReact = React.forwardRef(
}, [props.components]);

return (
<div
className={props.className}
style={{ height: '100%', width: '100%' }}
ref={domRef}
>
<div style={{ height: '100%', width: '100%' }} ref={domRef}>
{portals}
</div>
);
Expand Down
6 changes: 1 addition & 5 deletions packages/dockview/src/paneview/paneview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ export const PaneviewReact = React.forwardRef(
}, [props.onDidDrop]);

return (
<div
className={props.className}
style={{ height: '100%', width: '100%' }}
ref={domRef}
>
<div style={{ height: '100%', width: '100%' }} ref={domRef}>
{portals}
</div>
);
Expand Down
6 changes: 1 addition & 5 deletions packages/dockview/src/splitview/splitview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ export const SplitviewReact = React.forwardRef(
}, [props.components]);

return (
<div
className={props.className}
style={{ height: '100%', width: '100%' }}
ref={domRef}
>
<div style={{ height: '100%', width: '100%' }} ref={domRef}>
{portals}
</div>
);
Expand Down

0 comments on commit b3873a2

Please sign in to comment.