Skip to content

Incorrect Positioning of floating Panel in addPanel and fromJson Methods #318

@nicolab28

Description

@nicolab28

I am currently in the process of testing the JavaScript library using the dockview-core.esm.js module. During my testing, I encountered a bug related to the addPanel and fromJson methods.

The issue arises specifically when I utilize the attach(parent) function. In this context, the addPanel method with a specified floating position or the fromJson method fails to correctly position the panel as intended.

  const pane4 = dockview.addPanel({
    id: "panel_4",
    title: "Panel 4",
    component: "default",
    floating: { x: 222, y: 333, width: 300, height: 300 },
    // floating: true,
  });

Upon investigating, I noticed that the issue originates from the setBounds method within the Overlay class. This method retrieves the containerRect using the following line:

const containerRect = this.options.container.getBoundingClientRect();

However, the containerRect always seems to be returning values of 0, which affects the calculation of the panel's position (top and left) due to the subsequent clamp operation.

This leads to the panel consistently being positioned at 0, regardless of the intended position.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions