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

refactor: fix <TextEdit /> bugs #1356

Merged
merged 2 commits into from
Dec 29, 2022

Conversation

AshotN
Copy link
Contributor

@AshotN AshotN commented Dec 24, 2022

<TextEdit /> currently has a few issue, and it's something that causes a lot of issues for me

  1. If the user has a field which the value of is currently null, there is no way for the user to know null vs blank.
  2. If the current field is null and during an edit the user focuses the field but makes no changes, during a save the client will tell the server that the value is "" for strings or 0 for numbers. This is an issue where an edit is made without the user even knowing it happened, this can cause validation errors and/or other issues.
  3. The component is overly complex and uses odd event listeners like onBlur and onKeyDown which is unnecessary.
  4. The useEffect seemingly does nothing

This PR contains a fix to <TextEdit />

But in addition has a feature proposal that I haven't ironed out yet. I propose to add some form of a reset for the field, it would make it clear to the user that the field has been edited. I have the functionality working, but the styling is pretty bad.

This video showcases the fix for <TextEdit /> as you are able to focus and unfocus without value change.
The "Reset" text will only show for a field that has been modified.

The "Price per" field is actually not fixed since currency type doesn't use the same <TextEdit /> component, so the old behavior is evident there.

recording

feat: show <null> as placeholder in text edit fields when value is null
feat: add `Reset` label to allow easy reseting to original value during edit
@AshotN AshotN marked this pull request as draft December 24, 2022 10:20
@matex1024 matex1024 requested a review from dziraf December 27, 2022 07:56
fix: only show on edit
@AshotN
Copy link
Contributor Author

AshotN commented Dec 29, 2022

image

Perhaps buttons instead would look better?

@matex1024 matex1024 marked this pull request as ready for review December 29, 2022 12:14
@matex1024 matex1024 merged commit 2478afe into SoftwareBrothers:master Dec 29, 2022
@github-actions
Copy link

github-actions bot commented Jan 2, 2023

🎉 This PR is included in version 6.7.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants