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

Inconsistent minimumHeight after refresh when using setConstraints #869

Open
zengyumei opened this issue Mar 10, 2025 · 0 comments
Open

Comments

@zengyumei
Copy link

Describe the bug

  1. When setting panel constraints via group.api.setConstraints({ minimumHeight: 50 }), the minimum height works correctly during runtime but reverts to the default 100px after page refresh. This occurs because addPanel uses a default minimumHeight: 100px if not explicitly provided, overriding the dynamically set constraint.
  2. When initial constraints are set via addPanel parameters (e.g., minimumHeight: 200), subsequent calls to panelGroup.api.setConstraints({ minimumHeight: 50 }) fail to override the initial values. This creates an irreversible constraint configuration where dynamic constraint updates are ignored.

To Reproduce
https://codesandbox.io/p/sandbox/dawn-glade-8xq494

Steps to reproduce the behavior:
For the first question:

  1. Add a panel without specifying minimumHeight minimumWidth :
props.api.addPanel({
    id: 'panel_1',
    component: 'default',
});
  1. Set constraints:
props.api.group.api.setConstraints({
    minimumWidth: 50,
    minimumHeight: 50,
});
  1. Resize the panel vertically - it correctly respects 50px minimum.
  2. Refresh the page - the panel height jumps to 100px.

For the second question:
1.Add panel with initial constraints:

props.api.addPanel({
    id: 'panel_1',
    component: 'default',
    minimumWidth: 200, // initial minimumWidth
});
  1. Set constraints:
props.api.group.api.setConstraints({
    minimumWidth: 50,
    minimumHeight: 50,
});
  1. Observe panel still enforces 200px minimum height

Expected behavior

  1. The minimumHeight set via setConstraints should persist after refresh, or at least not be overridden by the default 100px value from addPanel
  2. The setConstraints API should always take precedence over initial values set in addPanel, allowing runtime constraint adjustments regardless of initialization parameters.

Technical Analysis
The constraint system appears to have this priority order:
addPanel parameters > setConstraints > group defaults
When it should be:
Active setConstraints > addPanel parameters > group defaults

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Browser: Chrome 131
  • macOS : 14.2

Additional context
The issue arises because addPanel defaults minimumHeight to 100px. When the layout reinitializes after refresh, it uses this default value instead of the dynamically set constraint.

Expected resolution: Either:
Allow setConstraints to override the default values permanently, or
Make addPanel inherit constraints set via setConstraints during initialization.

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

1 participant