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

tonic-input without id causes value to be lost #31

Closed
Raynos opened this issue Oct 24, 2019 · 5 comments
Closed

tonic-input without id causes value to be lost #31

Raynos opened this issue Oct 24, 2019 · 5 comments

Comments

@Raynos
Copy link
Member

Raynos commented Oct 24, 2019

If a tonic-input does not have an id attribute then when you type in it and re-render the component the text that was typed is lost.

You need to add an id attribute to tonic-input

@heapwolf
Copy link
Member

heapwolf commented Oct 25, 2019

This is by design, but I'm not sure the developer experience is correct. Basically, id says, this is a significant component that should retain its state across re-renders. But, it's not intuitive, perhaps we should have an attribute that indicates this? maybe persistent=true?

@Raynos
Copy link
Member Author

Raynos commented Oct 27, 2019

Hmm, emphemereal=true might be a good option.

I think not persisting the state can lead to bad UX.

Is there a use case for not setting id on tonic-input ?

Cleaning the end users text upon reRender is a bad experience.

@Raynos
Copy link
Member Author

Raynos commented Oct 27, 2019

My suggested solution would be to add a check for props.id in the render method of tonic-input and throw an exception if it’s missing

@heapwolf
Copy link
Member

Some inputs are optional, their values don't need to be remembered, but that might be the unimportant case. So we are saying we should just remember a component's state by default. I think that's pretty reasonable actually.

@Raynos Raynos closed this as completed Nov 10, 2019
@Raynos
Copy link
Member Author

Raynos commented Nov 10, 2019

This is not possible to implement.

We can either :

  • do the current behavior of only persisting state for Tonic components that have an id field
  • Or add a new gaurd in the render() method of some components like tonic-input that make the id field mandatory and force developers to set it.

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