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

Whinepad: Let 0 be defaultValue of rating for a new record #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pedrottimark
Copy link

@pedrottimark pedrottimark commented Oct 21, 2016

Problem: If you do not click a star when you add a new records, the value of rating is NaN because of parseInt('', 10). JSON.stringify writes NaN as null, therefore toString will fail during some text searches in the next session when the data has been deserialized.

Solution: Delete conditional expression and parseInt at intermediate levels of the component tree so leaf components receive undefined as defaultValue of fields for a new record.

Steps to verify with console pane open in the browser:

  1. Given the default record, type z in the search box. Actual and expected result is no records match.
  2. Click add and then click Add to add an empty record.
  3. Type z in the search box. Actual and expected result is no records match.
  4. Type nan in the search box. Unexpected result is the new record matches.
  5. Clear the search box, and then refresh the page to cause Whinepad to read the data from storage.
  6. Type z in the search box. Unexpected result is TypeError: row[fields[f]] is null

Sorry about the whitespace changes. Atom editor has to make its mark ;)

P.S. Thank you very much for writing React Up & Running! Your previous JavaScript Patterns was super helpful to me too.

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

Successfully merging this pull request may close these issues.

1 participant