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

Number fields in app configurations silently default to 0 if no value is input by the user #82

Open
shiruken opened this issue Jul 26, 2024 · 0 comments
Labels
bug synced This issue has been added to our internal tracker

Comments

@shiruken
Copy link
Contributor

Info

App configuration fields of type number only allow inputting numeric values. However, if the user clears the field and clicks submit, Devvit silently sets the value to 0 without any indication. The user would not see this change unless they refresh the settings page.

For the app developer, this is impossible to handle when 0 is a valid value for the field. This breaks using input validation to make a field required since event.value = 0.

Potential Fix

settings.get() and settings.getAll() suggest that undefined is a valid value for settings:

get<T = string | string[] | boolean | number>(name: string): Promise<T | undefined>;

export type SettingsValues = { [key: string]: string | string[] | boolean | number | undefined };

Devvit should set fields of type number equal to undefined when the submitted field was empty. This will allow for using input validation to require the field when 0 is a valid value for the field.

@pl00h pl00h added bug synced This issue has been added to our internal tracker labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug synced This issue has been added to our internal tracker
Development

No branches or pull requests

2 participants