User has no way of knowing that a required prop needs an example value

[#3574668]

🤖 Claude code was used to help with this MR:

This MR

  • adds prefilled example values when a prop is marked required
  • adds a message in the UI if an example value is empty while it is required
    • "A required prop must have an example value."
  • prefills default example when changing type on a required prop
  • added unit tests for required prop example validation in Props.test.tsx

⚠️ It does not prevent the user from creating a required prop with an empty example value. But hopefully with 2 guardrails of prefilling the example value and also showing a message in the UI, that is enough for now. I think the user is responsible for making sure the example value exists now.

Things considered:

  • I thought about not updating the store if a user marked a prop required with no example value, but I think having the UI not reflect the redux store would make things confusing, because the UI would show it marked required, but the store would not reflect that.
  • An internal component has the "Add to components" button that will prevent the user from creating a required prop with an empty example but exposed components don't have an "action button" to check for validations, it just gets auto-saved every 10 seconds
Edited by Harumi Jang

Merge request reports

Loading