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

Placeholder not working #4494

Open
4 tasks done
paulcdd opened this issue Feb 12, 2025 · 2 comments
Open
4 tasks done

Placeholder not working #4494

paulcdd opened this issue Feb 12, 2025 · 2 comments

Comments

@paulcdd
Copy link

paulcdd commented Feb 12, 2025

Prerequisites

What theme are you using?

core

Version

5.16.1

Current Behavior

Placeholder not working. Link to playground example

https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJEQlNCYXNpY1JlcXVlc3RDb2xsZWN0aW9uIjp7IkVtcGxveWVyTmFtZSI6IiIsIkVtcGxveW1lbnRTZWN0b3IiOiIifX0sInNjaGVtYSI6eyJkZWZpbml0aW9ucyI6eyJFbXBsb3ltZW50Ijp7InR5cGUiOiJzdHJpbmciLCJlbnVtIjpbIjQ2NTdDNEY2LTIzMjYtNEIwRi05ODkxLUU5OTU2Mjg3Q0Y5NiIsIjFFRkYxQzVELUYxMkQtNDU0Ny1BRTM0LTMwN0Q2RjIzRTMxRSIsIjgzNzlFQzE4LUU5NEQtNDg1RC1BMzcwLTVCRERGMjMxMzgwRSJdLCJlbnVtTmFtZXMiOlsiTG9jYWwgR292ZXJubWVudCIsIkNlbnRyYWwgR292ZXJubWVudCIsIlB1YmxpYyBTZWN0b3ItT3RoZXIiXX19LCJwcm9wZXJ0aWVzIjp7IkRCU0Jhc2ljUmVxdWVzdENvbGxlY3Rpb24iOnsidHlwZSI6Im9iamVjdCIsInRpdGxlIjoiIiwicmVxdWlyZWQiOlsiRW1wbG95ZXJOYW1lIiwiRW1wbG95bWVudCJdLCJwcm9wZXJ0aWVzIjp7IkVtcGxveWVyTmFtZSI6eyJ0eXBlIjoic3RyaW5nIiwidGl0bGUiOiJFbXBsb3llciBOYW1lIiwiZGVmYXVsdCI6IiIsIm1heExlbmd0aCI6NjR9LCJFbXBsb3ltZW50Ijp7InR5cGUiOiJzdHJpbmciLCIkcmVmIjoiIy9kZWZpbml0aW9ucy9FbXBsb3ltZW50IiwidGl0bGUiOiJFbXBsb3ltZW50IFNlY3RvciIsImRlZmF1bHQiOiIiLCJtYXhMZW5ndGgiOjY0fX19fX0sInVpU2NoZW1hIjp7InVpOm9yZGVyIjpbIkRCU0Jhc2ljUmVxdWVzdENvbGxlY3Rpb24iXSwiREJTQmFzaWNSZXF1ZXN0Q29sbGVjdGlvbiI6eyJ1aTpvcmRlciI6WyJFbXBsb3llck5hbWUiLCJFbXBsb3ltZW50Il0sIkVtcGxveW1lbnQiOnsidWk6cGxhY2Vob2xkZXIiOiJDaG9vc2UgT25lIn19fSwidGhlbWUiOiJkZWZhdWx0IiwibGl2ZVNldHRpbmdzIjp7InNob3dFcnJvckxpc3QiOiJ0b3AiLCJleHBlcmltZW50YWxfZGVmYXVsdEZvcm1TdGF0ZUJlaGF2aW9yIjp7ImFycmF5TWluSXRlbXMiOnsicG9wdWxhdGUiOiJwb3B1bGF0ZSIsIm1lcmdlRXh0cmFEZWZhdWx0cyI6ZmFsc2V9LCJhbGxPZiI6InNraXBEZWZhdWx0cyIsImNvbnN0QXNEZWZhdWx0cyI6ImFsd2F5cyIsImVtcHR5T2JqZWN0RmllbGRzIjoicG9wdWxhdGVSZXF1aXJlZERlZmF1bHRzIiwibWVyZ2VEZWZhdWx0c0ludG9Gb3JtRGF0YSI6InVzZUZvcm1EYXRhSWZQcmVzZW50In0sIm9taXRFeHRyYURhdGEiOmZhbHNlLCJsaXZlT21pdCI6ZmFsc2UsIm5vVmFsaWRhdGUiOmZhbHNlLCJub0h0bWw1VmFsaWRhdGUiOmZhbHNlLCJkaXNhYmxlZCI6ZmFsc2V9LCJ2YWxpZGF0b3IiOiJBSlY4In0=

Expected Behavior

The Employment Sector should display Choose One

Steps To Reproduce

Environment

- OS: Ubuntu 22.04
- Node: 20.18.2
- npm:10.8.2

Anything else?

No response

@paulcdd paulcdd added bug needs triage Initial label given, to be assigned correct labels and assigned labels Feb 12, 2025
@nickgros
Copy link
Contributor

@paulcdd The issue goes away if you remove the default value "", which is not a valid value for your enumeration.

In #4200 (to fix #4197) we changed this so the placeholder is only shown if the default value is undefined.

@heath-freenome Would it make sense for us to change this behavior add a case to show the placeholder if the default value is the empty string AND the empty string is not included in the enumOptions?

@heath-freenome
Copy link
Member

@nickgros @paulcdd I would suggest we add a console.error() when someone has a default value that is not in the list of options for an enum. It seems like this is a situation where the JSON Schema is incorrectly defined and the UI is doing what it was asked.

@heath-freenome heath-freenome added awaiting response and removed bug needs triage Initial label given, to be assigned correct labels and assigned labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants