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

The number fields are really glitchy #72

Open
othyn opened this issue Jul 5, 2023 · 5 comments
Open

The number fields are really glitchy #72

othyn opened this issue Jul 5, 2023 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@othyn
Copy link
Owner

othyn commented Jul 5, 2023

Description

Its been a problem since the apps inception, but as SwiftUI doesn't have a numeric only field, you have to fudge the TextField with support which is what this app has been running on.

However, this has changed somewhat since this app was first made and there are better ways to handle updates:

https://www.hackingwithswift.com/quick-start/swiftui/how-to-format-a-textfield-for-numbers

I need to review the fields and make support better as at the moment, they're glitchy as anything. Especially when trying to change the field from something like 1 to 5 seconds as you can never remove the 1 as it won't let you empty the field.

Version

latest

Steps to Reproduce

See description.

Screenshots

No response

Device

Any Mac

Operating System

macOS 13.x

Additional Context

No response

@othyn othyn added the bug Something isn't working label Jul 5, 2023
@othyn othyn self-assigned this Jul 5, 2023
@othyn othyn added this to the Next Release milestone Jul 5, 2023
@caneeeeee
Copy link
Contributor

Any specific approach you've wanted to integrate this? I may create a PR.

@othyn
Copy link
Owner Author

othyn commented Feb 1, 2025

Oh nice! Yeah that'd be good. Nothing specific, UI wise I'd want them to appear the same. The main issue is that at the moment they are Text fields with fudgy reactive validation, but that causes things to behave weirdly. Since making this app, there are far better ways now available in Swift UI to natively do what I had to do hackily at the time. A nice refactor is on the cards:

https://www.hackingwithswift.com/quick-start/swiftui/how-to-format-a-textfield-for-numbers

Its mainly so in the use case of say having the field filled with 1, it won't let you empty the field to then enter 5 as the realtime validation won't allow the field to be empty.

It needs to not be empty on start, so the validation trigger could be moved I guess. But the main thing is to just try to make them feel less finicky and more reliable with what you'd expect with something like a HTML Number field. As at the time of making this app, there wasn't a native Number field in Swift UI that only allowed numbers to be entered.

@caneeeeee
Copy link
Contributor

Okay perfect, i'll try to read and look into this next week.

@caneeeeee
Copy link
Contributor

Quick Question, is there a reason why the validation is called twice? once in DynamicNumberField and once in NumberField.

@othyn
Copy link
Owner Author

othyn commented Feb 1, 2025

It's so long ago, honestly no idea. Could be an abstraction artifact. Could be a bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants