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

State is not preserved between tabs #2

Open
hfirst opened this issue Nov 8, 2024 · 1 comment
Open

State is not preserved between tabs #2

hfirst opened this issue Nov 8, 2024 · 1 comment

Comments

@hfirst
Copy link

hfirst commented Nov 8, 2024

I added a checkbox to your Product Details tab. I check the box on. I then switch to another tab and then back again. The checkbox is now unchecked.

export function ProductGeneralTab() {

  const [checked, setChecked] = useState(false);

  const handleChange = () => {
    setChecked(!checked);
  };

  return ( 
      <div>
          <div>
            General
          </div>
          <div>
            <label>
              <input
                type="checkbox"
                checked={checked}
                onChange={handleChange} />
              My Value
            </label>

            <p>Is "My Value" checked? {checked.toString()}</p>
          </div>
        </div> 
      );
}
@layerok
Copy link
Owner

layerok commented Nov 8, 2024

Yeah, this is not yet implemented. We need some kind of mechanizm of saving and restoring the tab's ui state. I am still in the process of figuring this out.

Where to save the state?

  1. localStorage/sessionStorage
  2. memory
  3. url
  4. database
  5. ...

When to save the state?

  1. On form field change. When the user checked the checkbox.
  2. On active tab change. When the user switched the tab.
  3. setInterval
  4. ...

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

2 participants