johnwalley / allotment

A React component for resizable split views
https://allotment.mulberryhousesoftware.com/
MIT License
949 stars 52 forks source link

Panes do not resize when providing the onReset event #803

Closed riazus closed 4 months ago

riazus commented 4 months ago

First of all, thanks for this awesome library.

I encountered a problem when using the onReset callback: the current implementation doesn't use the default resizing mechanism for the panes. Instead, it only calls the onReset handler.

For example, if I want to add some logic, I must also provide logic for changing the sizes.

<Allotment onReset={() => {
    // ... some logic
    base.onReset();
  }}
/>

Probably, we could call the default resizing implementation regardless of the nullability of the onReset callback?

src/allotment.tsx


if (onReset) {
onReset();
} else {
splitViewRef.current?.distributeViewSizes();

for (let index = 0; index < views.current.length; index++) { resizeToPreferredSize(index); } }



I'm open to feedback and suggestions.
loki344 commented 4 months ago

Yup, can confirm this issue, either provide the default onReset as a parameter, or always execute it