junsikshim / react-pane-system

A declarative, flexible pane layout system for React projects.
MIT License
6 stars 1 forks source link

Fix not expanding immediately #10

Closed hchangjae closed 6 months ago

hchangjae commented 7 months ago

MR for the fix on content width not expanding immediately on drag.

Work is still underway

junsikshim commented 6 months ago

Maybe relying on the CSS width and height is the problem. We might have to insert the parent's dimension as a prop to the child pane system.

hchangjae commented 6 months ago

Noticed components with "splitter props" may be restricted from having auto size. Suggest adding validation logic or decoupling this correlation. Will address in a separate PR for clarity.

hchangjae commented 6 months ago

Maybe relying on the CSS width and height is the problem. We might have to insert the parent's dimension as a prop to the child pane system.

In SystemPane, isn't the asynchronous update of rowHeightPxs via useEffect, triggered by changes in the container size (even if received as props), causing potential synchronization issues? If the update cycle is delayed by one step due to useEffect, a similar issue might arise 🤔. (In this case, it seems that PaneRow might be the root cause of the issue. However, since it shares the same structure)

I'll check the mentioned point along with your observations.

hchangjae commented 6 months ago

Still experiencing the issue even after removing delays caused by useEffect.

junsikshim commented 6 months ago

Applying useLayoutEffect instead of useEffect is not working, so I suspect that the delay is coming from the time gap between Pane and the inner PaneSystem. The inner one is relying on the CSS width(100%), and it might need an extra frame to recalculate the pixels.

  1. Pane resizes.
  2. The browser expands the inner PaneSystem's width based on its value(100%).
  3. The inner PaneSystem recalculates the actual pixel width.

The steps 1 through 3 should be done in one frame in order to be smooth, but I guess they're not.

hchangjae commented 6 months ago

I thought maintaining style changes through CSS might be necessary for PaneSystem to seamlessly blend with other components. However, would it be better if PaneSystem handles its styles only using its own settings?

junsikshim commented 6 months ago

I agree that PaneSystem benefits from using CSS as its style format, and the problem only exists when a PaneSystem is inside another PaneSystem. So I thought if a PaneSystem is a nested one, it could get the dimension from the parent Pane as props instead.

But this is only hypothetical, I'm not sure if this will solve the problem or not :)

hchangjae commented 6 months ago

Confirmed proper functionality by synchronizing timing with consistent width prop (as suggested). Ready to address changes for issue #11.

https://github.com/junsikshim/react-pane-system/assets/52942171/b8eb0aa7-0b97-4122-91a2-cca877c8c425

junsikshim commented 6 months ago

I'm currently working on #11 , so let's merge this first when it's ready.

junsikshim commented 6 months ago

It's ready to merge!