Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactively changing splitter size causes errors in solid in 1.0 #2277

Closed
iyefrat opened this issue Feb 24, 2025 · 6 comments
Closed

Reactively changing splitter size causes errors in solid in 1.0 #2277

iyefrat opened this issue Feb 24, 2025 · 6 comments

Comments

@iyefrat
Copy link

iyefrat commented Feb 24, 2025

🐛 Bug report

In solid-js, calling api.setSize in a createEffect leads to an

Uncaught Error: Total size of panels cannot be greater than 100

error, even if we change the sizes an order where this shouldn't happen.
This did not happen on 0.82.2, I encountered this while doing the 1.0 migration.

💥 Steps to reproduce

  1. Go to https://stackblitz.com/edit/sb1-whqjvvup?file=src%2FApp.tsx
  2. Note that in ResizeButton, we first reduce the size of a, and only then increase the size of b
  3. click on open preview in new tab button so we can easily see console errors
  4. click on resize
  5. get Uncaught Error: Total size of panels cannot be greater than 100 in console
    6 get the error again if we try to resize after this point

💻 Link to reproduction

https://stackblitz.com/edit/sb1-whqjvvup?file=src%2FApp.tsx

🧐 Expected behavior

For the reisze to happen and not through

🧭 Possible Solution

I'm not sure what the correct under-the-hood solutions here would be, but there are two things that would improve this area imo:

  1. a setSizes function that lets you save multiple sizes at once, so we don't have to reason about the order that setSize calls have to happen to not trigger the error
  2. a .getSize function for easier runtime debugging of what's going on

🌍 System information

Software Version(s)
Zag Version 1.0.1
Browser Chrome 133.0.6943.98
Operating System MacOS Seqouia 15.0.1

📝 Additional information

There is another (probably unrelated) issue - when dragging the resize separator, if it's close to the side it'll jump initially on the start of the drag, see video produced on the reproduction link:

Screen.Recording.2025-02-24.at.12.54.37.mov
@iyefrat iyefrat changed the title Reactively changing splitter size causes errors in solid Reactively changing splitter size causes errors in solid in 1.0 Feb 24, 2025
@segunadebayo
Copy link
Member

segunadebayo commented Feb 24, 2025

Thanks for opening this detailed issue.

This is a duplicate of #2261 and #2109, and it existed in the v0 versions.

I will get to those shortly

@iyefrat
Copy link
Author

iyefrat commented Feb 25, 2025

Whoops you're right - on my actual code it doesn't occur on 0.82.2, but on the reproduction in stackblitz it does, there must be some extra thing cancelling out the issue on my actual code.

Thanks! Looking forward to completing the migration once this is fixed :)

@iyefrat
Copy link
Author

iyefrat commented Feb 25, 2025

Wait actually I was wrong in my previous comment - on 0.82.2 in the stackblitz (current state), If you follow the reproduction instructions there is no issue. We only hit the Uncaught Error: Total size of panels cannot be greater than 100 error if we drag the splitter to a < 30, thereby hitting a total size of over 100 in the intermediate state. In 1.0 you get the error even when managing order of events correctly

@iyefrat
Copy link
Author

iyefrat commented Mar 11, 2025

@segunadebayo do you know when you will get to fixing this issue (and the related #2261 and #2109 )? As my above comment says, this isn't actually a duplicate, this behavior is a regression from 0.82.2 and is preventing us from upgrading to 1.0.

@anubra266 anubra266 reopened this Mar 11, 2025
@segunadebayo
Copy link
Member

Temp. solution for this is to call the api.setSize within a microtask

  createEffect(() => {
    if (buttonStatusGetter()) {
      untrack(() => {
        queueMicrotask(() => {
          props.api.setSize("a", 30)
          props.api.setSize("b", 70)
        })
      })
    }
  })

Love the idea of setSizes and getSize. Will add those shortly.

@segunadebayo
Copy link
Member

Pushed a fix for this. I will get to the initial jumping issue pretty soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants