-
Notifications
You must be signed in to change notification settings - Fork 357
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
fix(Wizard): added prop to focus content on next/back #10285
Changes from all commits
ae63285
ae016cd
386180b
5b5a690
bf7318d
a2061ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ export const WizardNavItem = ({ | |
content = '', | ||
isCurrent = false, | ||
isDisabled = false, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
isVisited = false, | ||
stepIndex, | ||
onClick, | ||
|
@@ -68,23 +69,6 @@ export const WizardNavItem = ({ | |
console.error('WizardNavItem: When using an anchor, please provide an href'); | ||
} | ||
|
||
const ariaLabel = React.useMemo(() => { | ||
if (status === WizardNavItemStatus.Error || (isVisited && !isCurrent)) { | ||
let label = content.toString(); | ||
|
||
if (status === WizardNavItemStatus.Error) { | ||
label += `, ${status}`; | ||
} | ||
|
||
// No need to signify step is visited if current | ||
if (isVisited && !isCurrent) { | ||
label += ', visited'; | ||
} | ||
|
||
return label; | ||
} | ||
}, [content, isCurrent, isVisited, status]); | ||
|
||
Comment on lines
-71
to
-87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting this aria-label was kinda interfering/producing extra noise with the |
||
return ( | ||
<li | ||
className={css( | ||
|
@@ -110,7 +94,6 @@ export const WizardNavItem = ({ | |
aria-disabled={isDisabled ? true : null} | ||
aria-current={isCurrent && !children ? 'step' : false} | ||
{...(isExpandable && { 'aria-expanded': isExpanded })} | ||
{...(ariaLabel && { 'aria-label': ariaLabel })} | ||
{...ouiaProps} | ||
> | ||
{isExpandable ? ( | ||
|
@@ -127,9 +110,12 @@ export const WizardNavItem = ({ | |
{content} | ||
{/* TODO, patternfly/patternfly#5142 */} | ||
{status === WizardNavItemStatus.Error && ( | ||
<span style={{ marginLeft: globalSpacerSm.var }}> | ||
<ExclamationCircleIcon color={globalDangerColor100.var} /> | ||
</span> | ||
<> | ||
<span className="pf-v5-screen-reader">, {status}</span> | ||
<span style={{ marginLeft: globalSpacerSm.var }}> | ||
<ExclamationCircleIcon color={globalDangerColor100.var} /> | ||
</span> | ||
</> | ||
)} | ||
</> | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Wizard, WizardStep } from '@patternfly/react-core'; | ||
|
||
export const WizardFocusOnNextBack: React.FunctionComponent = () => ( | ||
<Wizard shouldFocusContent title="Wizard that focuses content on next or back click"> | ||
<WizardStep name="Step 1" id="wizard-focus-first-step"> | ||
Step 1 content | ||
</WizardStep> | ||
<WizardStep name="Step 2" id="wizard-focus-second-step"> | ||
Step 2 content | ||
</WizardStep> | ||
<WizardStep name="Review" id="wizard-focus-review-step" footer={{ nextButtonText: 'Finish' }}> | ||
Review step content | ||
</WizardStep> | ||
</Wizard> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preface by saying I don't exactly love this 😆
So something I think we should consider is adding a new wrapper element to the actual Wizard step content. Right now we have a structure of:
(Note that Core does not have a bunch of empty divs with display none for steps whose content is not currently rendered, so maybe the intent was that
__main
element should be static and__main-body
dynamically renders step content? Curious as to whether we need these empty div's rendered in React at all.)When we could either add a wrapper element around the
.pf-v5-c-wizard__main
and thedisplay: none
elements, or havepf-v5-c-wizard__main
always rendered and whatever step content just gets placed in there (sopf-v5-c-wizard__main-body
and the empty div elements).Right now we allow preventing that
.pf-v5-c-wizard__main
from being rendered which will be an issue for this focus management. Having it always rendered and placing all the step contents in there, rather than each step content dynamically updating from an empty div to a div with class.pf-v5-c-wizard__main
would help with this focus management (shouldn't need to wait for the__main
element to render before placing focus since it'd always be rendered) as well as being able to set thearia-live
on it instead of thepf-v5-c-wizard__inner-wrap
element (which doing this, any updates to nav content will be announced which may or may not be wanted/beneficial).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely curious about what scenario we could have that wouldn't include a main. If we went the
aria-live
route this would be necessary. However, maybe it's ok if we avoid usingaria-live
for now. I typically see live regions used for things like updates/status, alerts, logs, etc. Like this article talks about, live regions typically aren't used for interactive content (and I imagine we'd expect wizard content to be interactive often). Based on our discussion, I agree that it probably makes sense to omitaria-live
for now and rely on the announcement of the shifted focus.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @mcoker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW the wizard is built very similarly to a page, so
__main
was intended to mimic the page main container. In both cases, it's more of a static, structural element of the layout, so I would expect content within it (__main-body
elements) to re-render, or possibly attributes and stuff on__main
to change, but not the whole element to re-render... though I suppose that would be fine as long as it didn't cause layout shifts or anything?