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

1-1320: allow you to update example with no pattern + update state better #4623

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Sep 6, 2023

While having a pattern when you have no example doesn't make a lot of sense, it's a problem that you can't delete the example after deleting the pattern: you previously had to remove the example before the pattern.

This PR fixes that by always allowing you to update the example, even if there is no pattern. Our server doesn't currently accept submitting an example with no pattern, but we could allow that if we want to (and probably just discard it on the back-end).

This PR also updates the validation of the example and the regex. There were more unhandled edge cases previously where the validation would disappear or be wrong. This should be fixed now. The new logic is that, whenever you update the either the pattern or the example, we check:

  • if you have an error in your pattern, no pattern, or no example, then delete the example error if it exists
  • have a well-formed pattern and an example then check if the example matches the pattern and add/delete an error accordingly

This does have some consequences: editing the pattern can render your example invalid. You'll also get immediate feedback instead of when you switch focus. I think this is often a bad pattern (giving the user too much negative feedback), but in terms of working with regexes, I think it might be a good thing. We also give immediate feedback today, so I don't think this is a regression.

Any thoughts are welcome.

@vercel
Copy link

vercel bot commented Sep 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 6, 2023 1:38pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Sep 6, 2023 1:38pm

@thomasheartman thomasheartman changed the title 1-1320: allow you to update example with no pattern 1-1320: allow you to update example with no pattern + update state better Sep 6, 2023
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern was invalid, so this is just a cleanup.

Comment on lines +239 to +241
onFocus={() => {
delete errors.name;
}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, focusing the project name would clear all errors, including the ones for the naming pattern. this is a bit overzealous, so we'll only clear the errors.name property here.

@thomasheartman thomasheartman merged commit 31ed96d into main Sep 7, 2023
13 of 15 checks passed
@thomasheartman thomasheartman deleted the 1-1320-allow-you-to-clear-the-example-when-the-pattern-is-empty branch September 7, 2023 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants