Bytecrowds / main

The frontend and main API repository.
MIT License
3 stars 1 forks source link

Numeric-only text reverting to empty string #14

Closed TudorZgimbau closed 1 year ago

TudorZgimbau commented 1 year ago

It appears that trying to store numeric-only text in a bytecrowd (such as 1, 234, etc.) will fail because of a faulty update triggered from the editor.

To summarise, the usual flow is:

  1. a user edits the editor's text
  2. the text gets saved into the database
  3. the user refreshes
  4. /update is called because of useEffect, but the editor's value matches the stored bytecrowd's one so no update happens on the database

However, with numeric-only text, on step 4 the editor's value starts with an empty string so that gets pushed to the database. Mixed text (such as characters ( 123 ), etc.) works, so I would say the problem is either in the database text insertion done or the frontend or in the server side data retrieval.

TudorZgimbau commented 1 year ago

After some investigations, it seems like the issue might be client-side. Will continue another time.

TudorZgimbau commented 1 year ago

The issue was numeric-only editorInitialText getting parsed as number for some reason. Fixed in https://github.com/Bytecrowds/main/commit/070a2d3439447078e71aff745eb9e0fb0942bbbf by manually converting to string .