nathancahill / split

Unopinionated utilities for resizeable split views
https://split.js.org/
MIT License
6.1k stars 448 forks source link

MinSize ignored if Split created on invisible DOM Elements #798

Open jakerdy opened 7 months ago

jakerdy commented 7 months ago

Hi, there is a problem with minSize. If Split created on hidden DOM node, this part of initialization logic at split.js @ 694, uses getBoundingClientRect. But if DOM nodes invisible at this moment (parent display:none) rect will be zero-sized, and minSize will be overwritten with 0 value. But obviously size is not === 0, it just invisible at the moment. When hidden Split became visible, it will ignore specified minSizes.

rhssiiy commented 3 months ago

If anyone is interested, there is a workaround:

const split = Split(..., {
    minSize: 0,
    onDrag: (sizes) => {
        if (sizes[0] < 10) split.setSizes([10, 90]);
        if (sizes[1] < 10) split.setSizes([90, 10]);
    }, ...

All sizes are in percentages.