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

feat(Wizard - next): Enhancements & updated types #7915

Merged
merged 1 commit into from
Oct 5, 2022

Conversation

jpuzz0
Copy link
Contributor

@jpuzz0 jpuzz0 commented Sep 1, 2022

What: Closes #7914

Might not want to review until unit tests are reviewed and merged here: #7731
This commit diff is what's new to this PR: 8a04839

@patternfly-build
Copy link
Contributor

patternfly-build commented Sep 1, 2022

@jpuzz0 jpuzz0 force-pushed the feature/wizard-next-enhancements branch from 7ee35eb to 9d6797e Compare September 1, 2022 14:19
@tlabaj tlabaj requested a review from mcarrano September 1, 2022 16:14
@jpuzz0 jpuzz0 force-pushed the feature/wizard-next-enhancements branch 2 times, most recently from 39dec9a to 55ac285 Compare September 6, 2022 13:57
Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

@jeffpuzzo this looks good with one exception. After discussing with the design team, we feel like the status icon that annotates a step in the menu should fall immediately after the item label, not right aligned like you have it. This would be similar to the way we place the help (?) on form elements. @mcoker should be able to provide input on standard spacing. It may be that we should have a core implementation? I can create a mockup, if necessary.

@mcoker
Copy link
Contributor

mcoker commented Sep 14, 2022

So that it will wrap with the text, it's probably best just to put it inline with the step content and apply a margin. Here I've used the sm margin, which is about 8px.

Screen Shot 2022-09-14 at 9 24 23 AM

Screen Shot 2022-09-14 at 9 24 12 AM

It may be that we should have a core implementation?

It looks like it should since it looks like the icon is created by our component based on a step status -

<Flex justifyContent={{ default: 'justifyContentSpaceBetween' }}>
{content}
{status === 'error' && <ExclamationCircleIcon color="var(--pf-global--danger-color--100)" />}
</Flex>

Then we can make sure the color, spacing, line wrapping, etc is correct.

@jpuzz0
Copy link
Contributor Author

jpuzz0 commented Sep 14, 2022

Thanks @mcarrano @mcoker for the feedback. I'll be making this change as soon as the PR this is branched off of is merged and am able to rebase/resolve some anticipated conflicts.

@jpuzz0 jpuzz0 changed the title feat(Wizard - next): Add more enhancements feat(Wizard - next): Enhancements & updated types Sep 15, 2022
@jpuzz0 jpuzz0 force-pushed the feature/wizard-next-enhancements branch 5 times, most recently from 2e046c6 to f665567 Compare September 19, 2022 15:49
@jpuzz0
Copy link
Contributor Author

jpuzz0 commented Sep 19, 2022

@jeffpuzzo this looks good with one exception. After discussing with the design team, we feel like the status icon that annotates a step in the menu should fall immediately after the item label, not right aligned like you have it. This would be similar to the way we place the help (?) on form elements. @mcoker should be able to provide input on standard spacing. It may be that we should have a core implementation? I can create a mockup, if necessary.

@mcarrano I've addressed this comment, and it can be visually tested in the Kitchen sink example when the PR surge link is available. Please let me know if there's anything else that is of concern that I should address in this PR.

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for making that update @jeffpuzzo !

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

This looks pretty solid, one bug: hitting back while on the first step of the kitchen sink example causes a type error
image

Also I think it would maybe be good for there to be some automatic a11y behavior (like a generated label if the consumer doesn't provide one) for Wizard steps that have an error status, since it seems that at the moment that status isn't communicated in an accessible way. Thoughts?

@jpuzz0
Copy link
Contributor Author

jpuzz0 commented Sep 23, 2022

automatic a11y behavior

The Back button was meant to be disabled for Step 1, which I'll fix now. Since that example uses a custom footer, that had to be done manually.

As for any labels for a11y having to do with the status of a Wizard step, I could conditionally add an aria-label to the nav item or maybe the error icon itself? I might defer to others on the team for best practices in that regard.

@jpuzz0
Copy link
Contributor Author

jpuzz0 commented Sep 23, 2022

As for any labels for a11y having to do with the status of a Wizard step, I could conditionally add an aria-label to the nav item or maybe the error icon itself? I might defer to others on the team for best practices in that regard.

@wise-king-sullyman I spoke with @nicolethoen about this who gave me some great pointers. I ended up adding a visited as well to show up conditionally in an aria-label, so the breakdown with a step label of Step label would be:

  1. If not visited and without an 'error' status, do not add an aria-label to the button
  2. If visited and not current, the screen reads Step label, visited
  3. If status === 'error', the screen reads Step label, error
  4. If visited, not current and status === 'error', the screen reads Step label, error, visited

Does this seem appropriate? (Question for both of you)

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Looks great to me! The only other thing I can think of that might be nice would be some usage of aria-live so that screen reader users are made aware of the content changes that occur.

I would be fine with that being done under a different issue though, so I'm going ahead and approving 🙂

- Sub-steps
- Step content with a drawer
- Custom nav item
- Disabled nav items until visited
Copy link
Contributor

Choose a reason for hiding this comment

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

"navigation" here as well.

- Custom footer
- Sub-steps
- Step content with a drawer
- Custom nav item
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to "navigation" instead of the abbreviated "nav".

@@ -37,6 +40,8 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
width?: number | string;
/** Custom height of the wizard */
height?: number | string;
/** Disables nav items that haven't been visited. Defaults to false */
forceStepVisit?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

typically we name our boolean props with prefixes such as "is", "are", "has".
maybe areUnvisitedStepsDisabled. Or something that along those lines.

@@ -37,6 +40,8 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
width?: number | string;
/** Custom height of the wizard */
height?: number | string;
/** Disables nav items that haven't been visited. Defaults to false */
forceStepVisit?: boolean;
/** Flag to unmount inactive steps instead of hiding. Defaults to true */
unmountInactiveSteps?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would update this prop name as mentioned above.

nextButtonText?: React.ReactNode;
/** Custom text for the Back button */
backButtonText?: React.ReactNode;
/** Custom text for the Cancel link */
cancelButtonText?: React.ReactNode;
/** Optional flag to disable the first step's back button */
/** Flag to disable the next button */
disableNextButton?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe isNextButtonDisabled

disableBackButton?: boolean;
/** True to hide the Cancel button */
hideCancelButton?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit isCancleButtonHidden

/** True to hide the Cancel button */
hideCancelButton?: boolean;
/** True to hide the Back button */
hideBackButton?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit isBackButtonHidden

@@ -6,9 +6,9 @@ export interface WizardNavProps {
/** children should be WizardNavItem components */
children?: any;
/** Aria-label applied to the nav element */
'aria-label'?: string;
ariaLabel?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why you renamed these aria attributes. The way you add it before is how we have them elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason outside of not wanting to access them in the internal wizard's navigation via bracket notation nav['aria-label'] vs nav.ariaLabel. I can revert since you're right in that elsewhere they are written as hyphenated and probably better to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with keeping them consistent, since 'aria-label' is also the name of the HTML attribute

}

export const WizardFooter = ({
export const WizardFooterWrapper: React.FunctionComponent = ({ children }) => (
<footer className={css(styles.wizardFooter)}>{children}</footer>
Copy link
Contributor

Choose a reason for hiding this comment

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

I am seeing a type error here. There is no interface defined for this component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you seeing a type error locally? FunctionComponent has an interface with optional children, which is why there should be no issue here;

interface FunctionComponent<P = {}> {
       (props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
       propTypes?: WeakValidationMap<P> | undefined;
       contextTypes?: ValidationMap<any> | undefined;
       defaultProps?: Partial<P> | undefined;
       displayName?: string | undefined;
   }
   
type PropsWithChildren<P> = P & { children?: ReactNode | undefined };

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup. It was locally when I pulled the branch.

/** Flag to determine whether the step is hidden */
isHidden?: boolean;
/** Content shown when the step's nav item is selected. When treated as a parent step, only sub-step content will be shown. */
component?: React.ReactElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to an internal prop. It added when you build the step correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, that should be removed.

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

An aside, but I think we usually use the component prop for this kind of thing?

The main issue I see is that we'll want to have the step number visible in the nav toggle on small screens. And we'll want to have status support on the step in core - in this PR it's done by hard-coding the danger color on the SVG and using a utility class to create space between the SVG and the step text (utility classes aren't included with PF by default - you have to import those separately)

- Custom navigation item
- Disabled navigation items until visited
- Action to toggle visibility of a step
- Action to toggle navigation item error status

Custom operations when navigating between steps can be achieved by utilizing `onNext`, `onBack` or `onNavByIndex` properties whose callback functions return the 'id' and 'name' of the currently focused step (currentStep), and the previously focused step (previousStep).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - punctuation

Suggested change
Custom operations when navigating between steps can be achieved by utilizing `onNext`, `onBack` or `onNavByIndex` properties whose callback functions return the 'id' and 'name' of the currently focused step (currentStep), and the previously focused step (previousStep).
Custom operations when navigating between steps can be achieved by utilizing `onNext`, `onBack`, or `onNavByIndex` properties whose callback functions return the 'id' and 'name' of the currently focused step (currentStep) and the previously focused step (previousStep).


const wizardNavProps: WizardNavProps = {
isExpanded: isNavExpanded,
'aria-label': nav?.['aria-label'] || 'Wizard navigation',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the default label should be, but fwiw the rotor menu will read this as "wizard navigation navigation" (because it's a <nav> element). For our page navigation, we use "Global" as the label for the main nav (either vertical or horizontal) and "Local" for tertiary nav and horizontal sub-nav. The existing wizard nav aria-label is "steps" in core, and "[example name] steps" in react. I wonder if it's best to stick with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to be 'Wizard steps' for now.

Comment on lines 119 to 120
{status === WizardNavItemStatus.Error && (
<ExclamationCircleIcon color="var(--pf-global--danger-color--100)" className="pf-u-ml-sm" />
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to add support for this in core, then bring it back here. Created an issue for that - patternfly/patternfly#5142

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. To be clear though, is this a blocking comment or something we can add back after this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine to add as a follow up if @mcoker is ok with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fine with me, though it's worth noting that the utility class will not work unless the utility class CSS has been imported either in the component or into the user's app. Assuming we want it to work in the interim, it could be rewritten as...

Suggested change
{status === WizardNavItemStatus.Error && (
<ExclamationCircleIcon color="var(--pf-global--danger-color--100)" className="pf-u-ml-sm" />
{status === WizardNavItemStatus.Error && (
<ExclamationCircleIcon color="var(--pf-global--danger-color--100)" style={{marginLeft: "var(--pf-global--spacer--sm)"}} />

@@ -97,10 +88,10 @@ export const WizardToggle = ({
>
<span className={css(styles.wizardToggleList)}>
<span className={css(styles.wizardToggleListItem)}>
{activeStep?.name}
{currentStep?.name}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing the toggleNum element here

<span className={css(styles.wizardToggleNum)}>{activeStepIndex}</span> {activeStepName}

This is what it should look like

Screen Shot 2022-10-04 at 5 02 01 PM

This is what it looks like now

Screen Shot 2022-10-04 at 5 01 51 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I think I lost this when resolving merge conflicts in or from the previous Wizard-next PR, will add this back, good catch!

@jpuzz0 jpuzz0 force-pushed the feature/wizard-next-enhancements branch from 0c7c4b7 to 09b7c6d Compare October 5, 2022 14:35
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM!

@jpuzz0 jpuzz0 force-pushed the feature/wizard-next-enhancements branch from d700058 to dfa260f Compare October 5, 2022 16:05
@tlabaj tlabaj merged commit 04f5004 into patternfly:main Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(Wizard - next): Additional features/enhancements
7 participants