Skip to content

Commit

Permalink
Fix incorrect values for modal sizing (#45)
Browse files Browse the repository at this point in the history
This fixes an issues where the fabric renderer would get the correct
sizing via onSizeChanged, write it to the shadow tree generating a state
update callback and then setting the wrong size using ModalHostManager.
Once onSizeChanged is fired by the OS it is treated as the definitive
source of truth for sizing.
  • Loading branch information
pmick authored Oct 11, 2023
1 parent 5dbedec commit 45887b4
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,21 @@ public void runGuarded() {
}
}

/**
* Updates the shadow tree via the local fabric view state manager. Can noop if the same values
* are passed multiple times. Can also ignore params if the local variables for viewWidth &
* viewHeight are non-zero.
*
* @param width target width of the container as pixels. Will be converted to DIP.
* @param height target height of the container as pixels. Will be converted to DIP.
*/
@UiThread
public void updateState(final int width, final int height) {
final float realWidth = PixelUtil.toDIPFromPixel(width);
final float realHeight = PixelUtil.toDIPFromPixel(height);
// Once viewWidth & viewHeight are set by an onSizeChanged callback they become our source
// of truth. This makes the fabric renderer function like the paper renderer is currently
// functioning.
final float realWidth = PixelUtil.toDIPFromPixel((viewWidth > 0) ? viewWidth : width);
final float realHeight = PixelUtil.toDIPFromPixel((viewHeight > 0) ? viewHeight : height);

// Check incoming state values. If they're already the correct value, return early to prevent
// infinite UpdateState/SetState loop.
Expand Down

0 comments on commit 45887b4

Please sign in to comment.