Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dialog] Add APIs to set position and dimension #1060

Closed
DiegoCardoso opened this issue Feb 19, 2020 · 6 comments
Closed

[dialog] Add APIs to set position and dimension #1060

DiegoCardoso opened this issue Feb 19, 2020 · 6 comments
Assignees
Labels

Comments

@DiegoCardoso
Copy link
Contributor

Developer could be able to set the coordinates (top, left) and dimension (width, height) of the overlay.

Two things that could be part of this:

  • A draggable event after dragging is done
  • Update resize event to add the top and left positions to its detail data (the reason is that so, dialog flow could sync these values on resize)
@DiegoCardoso DiegoCardoso changed the title Add API to set position to a dialog Add APIs to set position and dimension to a dialog Feb 19, 2020
@DiegoCardoso DiegoCardoso changed the title Add APIs to set position and dimension to a dialog Add APIs to set position and dimension of a dialog Feb 19, 2020
@ado2000
Copy link

ado2000 commented Aug 9, 2020

Hope to see this feature in next release.

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-dialog May 19, 2021
@vaadin-bot vaadin-bot added enhancement New feature or request Impact: High needs design Design is needed vaadin-dialog labels May 19, 2021
@DiegoCardoso DiegoCardoso changed the title Add APIs to set position and dimension of a dialog [dialog] Add APIs to set position and dimension Jul 15, 2021
@osenbg
Copy link

osenbg commented Nov 6, 2021

When will this feature available ?

@rolfsmeds
Copy link
Contributor

rolfsmeds commented Oct 7, 2024

  • We should avoid setting width/height on a postitioned-but-not-sized Dialog to avoid the problem that dragging currently has: Dialog no longer resizes automatically after dragging. #436
  • The left/top position should be reflected back to the server when a drag-move ends, so that the getters return the new values and the position can be restored with @PreserveOnRefresh.
  • Resize event needs to convey updated top/left coordinates as well.

@TatuLund
Copy link
Contributor

TatuLund commented Oct 7, 2024

It is possible to set the position using JavaScript, example is found here

https://github.com/TatuLund/mdi-demo/blob/master/src/main/java/com/example/application/components/window/Window.java#L222

@DiegoCardoso DiegoCardoso self-assigned this Oct 8, 2024
@DiegoCardoso
Copy link
Contributor Author

One problem with that is that the dragging of the dialog element can behave unexpectedly if the size is not set on drag. Take, for instance, the example in the dev/dialog.html page in our repo:

dialog-overlay-size.mp4

We set max-width in the root element (root.style.maxWidth = '40em';) passed to the renderer (which, essentially, is the vaadin-dialog-overlayelement. As can be seen at the start of the recording, the size of the element is what restricts thepart=overlayelement to expand horizontally to fit its content. When the user drags the element, since only thetopandleft` properties are being defined, the element will grow when moved to the left and shrink when it is moved to the right (until the point it no longer can shrink and the whole element will move).

If, however, we add a container to the content elements and define a size for this container instead of the root element:

      const container = document.createElement('div');
      container.style.maxWidth = '40em';
      container.style.minWidth = '20em';
      root.appendChild(container);

      // Add elements to `container`
      // ...
dialog-content-size.mp4

Then, the dragging will occur as expected with the change in the element shrinking when it moves to the right edge until it reaches its size limit.

@DiegoCardoso
Copy link
Contributor Author

@rolfsmeds rolfsmeds moved this to December 2024 (24.6) in Roadmap Nov 13, 2024
@rolfsmeds rolfsmeds removed the needs design Design is needed label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: December 2024 (24.6)
Development

No branches or pull requests

6 participants