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

Inline editor messes with the type of the edited value #115

Closed
uap-universe opened this issue Jan 18, 2023 · 1 comment
Closed

Inline editor messes with the type of the edited value #115

uap-universe opened this issue Jan 18, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@uap-universe
Copy link
Collaborator

Assume you have an object with number fields in it.

When you use this object as source for the smart table and enable inline editing, the following can be observed:

  • when you edit a value, it will be overwritten with a new value of type string
  • when you open the inline editor and immediately accept without making changes, the values will be left unchanged and keep their type

The consequence is that application code can never be sure what type the values actually have after editing.

The same is true btw. for null or undefined values. When you don't change anything, the original value remains untouched, keeping a possible null or undefined type. But if you touched the editor and for example entered some text and the remove the text again, the previous null value will be overwritten with an empty string.

So in other words: when the type of a column is T, the type of the data in a particular row (!) must be assumed as T | string. This is particularly relevant when you are doing some validation in the (confirmEdit) event handler.

@uap-universe
Copy link
Collaborator Author

We solve this the following way:

  • Clean up valuePrepareFunction and filterFunction #117 already forces the valuePrepareFunction to produce strings
  • we make the Cell to always use string internally
  • we make the newValue of the Cell private s.t. a new value can only be set via a method
  • we add an (optional) counter-part for the valuePrepareFunction to convert a string back to the actual type

Lacking a better name, we will call the new function valueStoreFunction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant