Skip to content

fix(formplayer): adate input issues and change to dropdown input format#351

Open
arthur-d42 wants to merge 2 commits intoOpenDataEnsemble:devfrom
BandimHealthProject:fix-aDate
Open

fix(formplayer): adate input issues and change to dropdown input format#351
arthur-d42 wants to merge 2 commits intoOpenDataEnsemble:devfrom
BandimHealthProject:fix-aDate

Conversation

@arthur-d42
Copy link

fix(formplayer): adate input broken for year, unknown toggle, and navigation

Description

Three bugs in AdateQuestionRenderer.tsx:

  1. Year input impossiblehandleYearChange regex /^\d{4}$/ rejected partial typing, making it impossible to enter a year character by character.
  2. "Unknown" checkbox didn't persist ?? — All handlers called updateFormData() synchronously after setState, but the useCallback closure captured stale state. Checking "Unknown" after entering a value never wrote ?? to storage.
  3. Error on navigate backisInitializing ref was set to false before React processed batched setState calls from init, causing the sync effect to overwrite real data with empty state on remount.

Fix: Replaced updateFormData callback with a reactive useEffect that syncs to the form whenever state changes. Added skipNextSync ref to prevent the sync effect from firing during initialization, and lastWrittenData ref to break the circular data prop feedback loop. Empty unfilled fields now default to NS so adateToStorageFormat always receives a parseable string.

Also switched day/month/year from TextField inputs to Select dropdowns to avoid partial typing issues and for ease of use.

Type of Change

  • Bug Fix
  • New Feature / Enhancement
  • Refactor / Code Cleanup
  • Documentation Update
  • Maintenance / Chore
  • Other (please specify):

Component(s) Affected

  • formulus (React Native mobile app)
  • formulus-formplayer (React web app)
  • synkronus (Go backend server)
  • synkronus-cli (Command-line utility)
  • Documentation
  • DevOps / CI/CD
  • Other:

Related Issue(s)

Closes/Fixes/Resolves:


Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manually tested
  • Tested on multiple platforms (if applicable)
  • Not applicable

Breaking Changes

  • This PR introduces breaking changes
  • This PR does NOT introduce breaking changes

Documentation Updates

  • Documentation has been updated
  • Documentation update is not required

Checklist

  • Code follows project style guidelines
  • All existing tests pass
  • New tests added for new functionality
  • PR title follows Conventional Commits format

@najuna-brian
Copy link
Contributor

Hello @arthur-d42, thanks for this and welcome to the Ode community ☺️
Please open a corresponding issue description for this PR (which should Ideally been the first 😀)

And may be we can discuss more in detail there?

@najuna-brian najuna-brian self-requested a review February 26, 2026 16:23
@najuna-brian
Copy link
Contributor

Hi @arthur-d42
May be we can have these prettier checks resolved?

Copy link
Contributor

@najuna-brian najuna-brian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go ahead and create the issue 😊

@arthur-d42
Copy link
Author

The issue has been created :)) Here

@najuna-brian
Copy link
Contributor

Thank you @arthur-d42

The file formulus-formplayer/src/renderers/AdateQuestionRenderer.tsx has Prettier formatting issues that are causing the CI check to fail.

To fix this, please run the following commands:

cd formulus-formplayer
npm run format:check -- --write

Or if you prefer to run Prettier directly:

cd formulus-formplayer
npx prettier "src/renderers/AdateQuestionRenderer.tsx" --write

@najuna-brian
Copy link
Contributor

after that, I believe it will be ready to merge 😊

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.

3 participants