-
Notifications
You must be signed in to change notification settings - Fork 6
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
Simplify data entry forms #964
base: main
Are you sure you want to change the base?
Conversation
Sigrid maintainability feedbackShow detailsSigrid compared your code against the baseline of 2025-03-05. 👍 What went well?
👎 What could be better?
📚 Remaining technical debt
View this system in Sigrid to explore your technical debt ⭐️ Sigrid ratings
💬 Did you find this feedback helpful?We would like to know your thoughts to make Sigrid better. |
Is this something that can be added to model based testing? changes popup inbetween sections? |
The behavior should now be the same across sections, though perhaps slightly different from main. |
These files were only used for data entry.
I've reached an illegal state with the steps below, which results in a backend error
|
# Conflicts: # frontend/app/module/data_entry/polling_station/AbortDataEntryControl.test.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Illegal state recounted==true but voters_recounts is None
seems to be fixed!
Created a new issue to add RTL tests for this behavior: #1137 |
@lkleuver Not sure if it's in scope for this PR, but if I have an expired session, I can still navigate through the form. And as part of each new page render, I get the "De sessie is ongeldig" error popup. I'd expect not to be able to navigate to a different page with an expired session. |
Not in scope for this PR, and also not something that was changed in this PR. When navigating to other parts of the form no requests are made (only when saving, either through the 'Volgende' button or the modal) so no session validation is done. |
It looks like the behaviour of the [X] button in the abort modal has changed compared to Reproduce using:
What happens:
Expected:
|
Fixes #850
This PR is an overhaul of the state management for the data entry forms.
It introduces a "reducer" to centralize state manipulation and simplify the data flow using events.
Apart from the central form state, the local form hooks and components are cleaned up, in particular the number of hard-to-reason-about
useEffect
anduseRef
hooks are removed.See
frontend/app/component/form/data_entry/state
for the hooks, context and providers related to the data entry state.Notes:
main
ASAPuseReducer
Other notes on React state management:
The data flow we try to adhere to
In our case events are triggered from the UI, which are dispatched to the central reducer. The reducer updates the otherwise immutable state object. The React components render this immutable state as a UI.
Don't overuse
useRef
From the React documentation:
Don't overuse
useEffect
From the React documentation:
Strive for simple components with unidirectional data flow
useRef
useEffect
to preload API data, or trigger explicit side-effectsuseMemo
anduseCallback
hooks should only be used if they prevents expensive calculations - in Abacus this is almost never the case!