iTwin / appui

Monorepo for iTwin.js AppUi
MIT License
8 stars 2 forks source link

Popout widget then setWidgetState(WidgetState.Hidden) #632

Open a-gagnon opened 7 months ago

a-gagnon commented 7 months ago

Describe the bug While testing the fixes in #524 , I noticed that my widget does not get re-rendered when going into popout mode. Because of that, the following line does not get reevaluated, and the close button is displayed:

const showCloseButton = (true !== UiFramework.frontstages.activeFrontstageDef?.isPopoutWidget(widgetId));

The associated code to closing the widget is this:

const widget = UiFramework.frontstages.activeFrontstageDef?.findWidgetDef(id);
widget?.setWidgetState(WidgetState.Hidden);

We hide the close button when in popout because it looks awkward having two 'X' stacked on top of each other (1 from the window frame and 1 from our UI). If we try to click on it while in a popout, we end up getting the infinite resize observer as discussed in #536

To Reproduce Steps to reproduce the behavior:

  1. Create a widget
  2. Popout widget
  3. Call setWidgetState(WidgetState.Hide) while in popout

Expected behavior Not sure what it should do, but that has to be predictable.

raplemie commented 7 months ago
  1. There is indeed no public event that I can see that would allow you to know that a widget was poped out, this could be an initial API to put in a hook as asked in #554
  2. Can you confirm if you normally close the widget (by closing the popout widget, NOT with the SetState) you get the expected behavior/No ResizeObserver issue ? If it's the case, that should help pinpoint the behavior difference on our side.
a-gagnon commented 7 months ago

Correct, if I close the popout, it brings my widget back to the panel where it was initially and I don't see the ResizeObserver warning.

raplemie commented 7 months ago

Hi @a-gagnon, 4.7.2 was released today and revert the change to the reparenting, this issue should be no longer be present. We will find a different solution to the initial issue. Let me know if we should close this issue.