Unplanned
Last Updated: 27 Sep 2024 05:02 by ADMIN
Hubert
Created on: 17 Jul 2024 07:55
Category: Window
Type: Bug Report
0
Window - changing position programmatically is not reliable

Setting the window position is not permanent.

How to reproduce:

  1. open https://stackblitz.com/edit/react-hyhjxg?file=app%2Fapp.tsx
  2. click 'move to corner' button
  3. click the window title bar
  4. the window changes its position to the previous one, but it should remain in place.

Chaging window stage also reverts previous position

 

 

1 comment
ADMIN
Konstantin Dikov
Posted on: 23 Jul 2024 12:53

Hi Hubert,

Thank you for contacting us.

The internal state of the Window will update when an event of the Window is fired and since the position is change manually outside of the Window events, the internal state will not update. However, you can manually update the state by using the Window ref and its setState method:

  const windowRef = React.useRef(null);

  const moveToCorner = () => {
    setPosition({ ...position, top: 70, left: 30 });
    windowRef.current.setState({ top: 70, left: 30 });
  };

  return (
    <div>
      <Button onClick={handleShowWindow}>Show/Hide</Button>
      <Button onClick={moveToCorner}>move to corner</Button>
      {opened && (
        <Window
          ref={windowRef}

Nevertheless, we will consider handling this internally when the position values are changed externally. 

 

Regards,
Konstantin Dikov
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024