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

Wizard: Add beforeNext conditions to Details step footer #2392

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

regexowl
Copy link
Collaborator

This adds beforeNext condition to the custom Details step footer, allowing to validate after clicking Next. That way the button is enabled, but gets disabled in the case validation errors and the helper text with the error renders immediately.

@regexowl
Copy link
Collaborator Author

regexowl commented Aug 29, 2024

@ezr-ondrej This is what I had in mind in #2305 (comment), what do you think? Would this make sense?

edit: to also add some arguments - this would be consistent with the FSC step, so it's a pattern we already use. The error wouldn't jump at the user prematurely, but at the time when they're happy with how they filled up the step and would like to continue. And this should also be compatible with the "always blue" strategy of Next button being always enabled unless there's a problem that need to be resolved.

@mgold1234
Copy link
Collaborator

looks good, just small suggestion

@regexowl
Copy link
Collaborator Author

regexowl commented Sep 3, 2024

To continue the discussion we had with @ezr-ondrej #2305 (comment) - does this make sense or not for our use case?

@lucasgarfield @mgold1234 With the way things are set up in PatternFly validation we have two options of showing the user validation errors. This will be specifically for the Details step's Blueprint name input, but there are several places where similar problem occurs (snapshot validation comes to mind):

  1. when a non-valid name is entered, we currently disable Next, but an error doesn't get rendered unless the user clicks outside of the input (onBlur). That means user can have the name filled in, can't continue because of disabled button, but doesn't see why.
  2. similarly to FSC step we could let the Next button be enabled, but disable it and render an error when the Next button with non-valid name filled in is clicked, which would be this PR.

A fair point is that the always enabled Next even with incorrect values might feel like a bait. On the other hand I feel it's a bit more transparent, but to be honest I'm very much undecided on this. What do you think?

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.19%. Comparing base (1a7350e) to head (dbb946a).
Report is 2222 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2392      +/-   ##
==========================================
+ Coverage   75.71%   84.19%   +8.48%     
==========================================
  Files          33      157     +124     
  Lines         597    17734   +17137     
  Branches      144     1764    +1620     
==========================================
+ Hits          452    14931   +14479     
- Misses        139     2782    +2643     
- Partials        6       21      +15     
Files with missing lines Coverage Δ
...Components/CreateImageWizard/CreateImageWizard.tsx 99.42% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8234d3...dbb946a. Read the comment docs.

@regexowl regexowl force-pushed the pristine-details-validation branch 3 times, most recently from dd717e9 to a4fdde9 Compare September 20, 2024 07:07
@regexowl regexowl force-pushed the pristine-details-validation branch 2 times, most recently from 31abc03 to 817f5db Compare September 25, 2024 13:34
@regexowl
Copy link
Collaborator Author

/retest

2 similar comments
@regexowl
Copy link
Collaborator Author

/retest

@regexowl
Copy link
Collaborator Author

/retest

Copy link
Collaborator

@mgold1234 mgold1234 left a comment

Choose a reason for hiding this comment

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

/lgtm

@mgold1234 mgold1234 enabled auto-merge (rebase) October 1, 2024 08:28
@regexowl regexowl force-pushed the pristine-details-validation branch 3 times, most recently from d5dcbd9 to 1f32f34 Compare October 2, 2024 08:00
@regexowl regexowl disabled auto-merge October 3, 2024 06:50
@regexowl regexowl force-pushed the pristine-details-validation branch 2 times, most recently from 8beb19e to 41a00a6 Compare October 4, 2024 07:46
@mgold1234 mgold1234 enabled auto-merge (rebase) October 7, 2024 07:03
Copy link
Collaborator

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Sorry for the delay here, I think this is a sane aproach 👍
Slight disadvantage is that we are still incorrect in some cases (you can't go next, but the button is blue). But it's better then the alternative today - keeping the button disabled even if you could continue and there is just lag.

@regexowl
Copy link
Collaborator Author

regexowl commented Oct 9, 2024

Aah right, this will break the IQE tests I guess. 🤔

The original behaviour of Details step when entering an invalid blueprint name was that the Next button got disabled, but no error was rendered.

The new behaviour should be that the Next button is enabled, but when clicking on it the validation kicks in, disables the button and the error gets immediately rendered (when the form is pristine only).

@jrusz @tkoscieln would you have time to take a look at this please? It's not urgent, we'll also probably need to support both scenarios while the changes are soaking in the stage.

This adds beforeNext condition to the custom Details step footer, allowing to validate after clicking Next. That way the button is enabled, but gets disabled in the case validation errors and the helper text with the error renders immediately.
@jrusz
Copy link
Collaborator

jrusz commented Oct 10, 2024

I see a bug with this. When I type an already existing blueprint name, the error is shown but the "Next" button is still enabled. It only gets disabled once clicked on. The test sees that it's enabled, clicks on it and then fails because it expects the Review step to appear.
image

@regexowl regexowl marked this pull request as draft October 10, 2024 10:05
auto-merge was automatically disabled October 10, 2024 10:05

Pull request was converted to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants