Skip to content

Commit e04055d

Browse files
committed
Feedback from Coker
1 parent 86fc9cb commit e04055d

4 files changed

Lines changed: 30 additions & 67 deletions

File tree

packages/react-core/src/components/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'r
111111
isCircle?: boolean;
112112
/** @beta Flag indicating the button is a docked variant button. For use in docked navigation. */
113113
isDocked?: boolean;
114-
/** @beta Flag indicating the dock button should display text. Only applies when isDocked is true. */
114+
/** @beta Flag indicating the docked button should display text. Only applies when isDocked is true. */
115115
isTextExpanded?: boolean;
116116
/** @hide Forwarded ref */
117117
innerRef?: React.Ref<any>;

packages/react-core/src/components/MenuToggle/MenuToggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface MenuToggleProps
5555
isSettings?: boolean;
5656
/** @beta Flag indicating the menu toggle is a docked variant. For use in docked navigation. */
5757
isDocked?: boolean;
58-
/** @beta Flag indicating the dock toggle should display text. Only applies when isDock is true. */
58+
/** @beta Flag indicating the docked toggle should display text. Only applies when isDocked is true. */
5959
isTextExpanded?: boolean;
6060
/** Elements to display before the toggle button. When included, renders the menu toggle as a split button. */
6161
splitButtonItems?: React.ReactNode[];

packages/react-core/src/components/Page/Page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
2424
variant?: 'default' | 'docked';
2525
/** @beta Flag indicating the docked nav is expanded on mobile. Only applies when variant is docked. */
2626
isDockExpanded?: boolean;
27-
/** @beta Flag indicating the docked nav should display text on desktop. Only applies when variant is docked. */
27+
/** @beta Flag indicating the docked nav should display text on desktop. Only applies when variant is docked, and will handle
28+
* setting isTextExpanded on individual isDocked components.
29+
* */
2830
isDockTextExpanded?: boolean;
29-
/** The horizontal masthead content (e.g. <Masthead />). When using the dock variant, this content will only render at mobile viewports. */
31+
/** The horizontal masthead content (e.g. <Masthead />). When using the docked variant, this content will only render at mobile viewports. */
3032
masthead?: React.ReactNode;
31-
/** @beta Content to render in the vertical dock when variant of dock is used. At mobile viewports, this content will be replaced with the content passed to masthead. */
33+
/** @beta Content to render in the vertical dock when variant of docked is used. At mobile viewports, this content will be replaced with the content passed to masthead. */
3234
dockContent?: React.ReactNode;
3335
/** Sidebar component for a side nav, recommended to be a PageSidebar. If set to null, the page grid layout
3436
* will render without a sidebar.

packages/react-core/src/demos/examples/Nav/NavDockedNav.tsx

Lines changed: 23 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,26 @@ export const NavDockedNav: React.FunctionComponent = () => {
171171
const mobileToggleRef = useRef<HTMLButtonElement>(null);
172172
const dockedToggleRef = useRef<HTMLButtonElement>(null);
173173

174-
const onToggleDock = () => {
175-
const willBeExpanded = !isDockExpanded;
176-
setIsDockExpanded(willBeExpanded);
177-
setIsDockTextExpanded(!isDockTextExpanded);
174+
const onMobileToggle = () => {
175+
setIsDockExpanded(!isDockExpanded);
178176

179-
// Shift focus between mobile and docked toggle buttons
180177
setTimeout(() => {
181-
if (willBeExpanded) {
182-
// Opening: focus the docked toggle button
183-
dockedToggleRef.current?.focus();
184-
} else {
185-
// Closing: focus the mobile toggle button
186-
mobileToggleRef.current?.focus();
187-
}
178+
dockedToggleRef.current?.focus();
188179
}, 200);
189180
};
190181

182+
const onToggleDock = () => {
183+
if (isDockExpanded) {
184+
setIsDockExpanded(!isDockExpanded);
185+
186+
setTimeout(() => {
187+
mobileToggleRef.current?.focus();
188+
}, 200);
189+
} else {
190+
setIsDockTextExpanded(!isDockTextExpanded);
191+
}
192+
};
193+
191194
// Mobile masthead - shown on mobile viewports only, hidden on desktop
192195
const mobileMasthead = (
193196
<Masthead display={{ default: 'inline' }} id="mobile-masthead">
@@ -198,7 +201,7 @@ export const NavDockedNav: React.FunctionComponent = () => {
198201
variant="plain"
199202
aria-label="Global navigation"
200203
isSidebarOpen={isDockExpanded}
201-
onSidebarToggle={onToggleDock}
204+
onSidebarToggle={onMobileToggle}
202205
isHamburgerButton
203206
/>
204207
</MastheadToggle>
@@ -244,7 +247,7 @@ export const NavDockedNav: React.FunctionComponent = () => {
244247
<Toolbar isVertical>
245248
<ToolbarContent>
246249
<ToolbarItem>
247-
<Nav onSelect={onNavSelect} variant="docked" isTextExpanded={isDockTextExpanded} aria-label="Global">
250+
<Nav onSelect={onNavSelect} variant="docked" aria-label="Global">
248251
<NavList>
249252
<NavItem
250253
preventDefault
@@ -312,80 +315,38 @@ export const NavDockedNav: React.FunctionComponent = () => {
312315
>
313316
<ToolbarItem>
314317
{isDockTextExpanded ? (
315-
<MenuToggle
316-
ref={appsRef}
317-
variant="plain"
318-
icon={<ThIcon />}
319-
isDocked
320-
isTextExpanded={isDockTextExpanded}
321-
aria-label="Applications"
322-
>
318+
<MenuToggle ref={appsRef} variant="plain" icon={<ThIcon />} isDocked aria-label="Applications">
323319
Applications
324320
</MenuToggle>
325321
) : (
326322
<Tooltip aria="none" aria-live="off" triggerRef={appsRef} content="Applications">
327-
<MenuToggle
328-
ref={appsRef}
329-
variant="plain"
330-
icon={<ThIcon />}
331-
isDocked
332-
isTextExpanded={isDockTextExpanded}
333-
aria-label="Applications"
334-
>
323+
<MenuToggle ref={appsRef} variant="plain" icon={<ThIcon />} isDocked aria-label="Applications">
335324
Applications
336325
</MenuToggle>
337326
</Tooltip>
338327
)}
339328
</ToolbarItem>
340329
<ToolbarItem>
341330
{isDockTextExpanded ? (
342-
<Button
343-
ref={settingsRef}
344-
aria-label="Settings"
345-
isSettings
346-
variant="plain"
347-
isDocked
348-
isTextExpanded={isDockTextExpanded}
349-
>
331+
<Button ref={settingsRef} aria-label="Settings" isSettings variant="plain" isDocked>
350332
Settings
351333
</Button>
352334
) : (
353335
<Tooltip aria="none" aria-live="off" triggerRef={settingsRef} content="Settings">
354-
<Button
355-
ref={settingsRef}
356-
aria-label="Settings"
357-
isSettings
358-
variant="plain"
359-
isDocked
360-
isTextExpanded={isDockTextExpanded}
361-
>
336+
<Button ref={settingsRef} aria-label="Settings" isSettings variant="plain" isDocked>
362337
Settings
363338
</Button>
364339
</Tooltip>
365340
)}
366341
</ToolbarItem>
367342
<ToolbarItem>
368343
{isDockTextExpanded ? (
369-
<MenuToggle
370-
ref={helpRef}
371-
variant="plain"
372-
icon={<QuestionCircleIcon />}
373-
isDocked
374-
isTextExpanded={isDockTextExpanded}
375-
aria-label="Help"
376-
>
344+
<MenuToggle ref={helpRef} variant="plain" icon={<QuestionCircleIcon />} isDocked aria-label="Help">
377345
Help
378346
</MenuToggle>
379347
) : (
380348
<Tooltip aria="none" aria-live="off" triggerRef={helpRef} content="Help">
381-
<MenuToggle
382-
ref={helpRef}
383-
variant="plain"
384-
icon={<QuestionCircleIcon />}
385-
isDocked
386-
isTextExpanded={isDockTextExpanded}
387-
aria-label="Help"
388-
>
349+
<MenuToggle ref={helpRef} variant="plain" icon={<QuestionCircleIcon />} isDocked aria-label="Help">
389350
Help
390351
</MenuToggle>
391352
</Tooltip>

0 commit comments

Comments
 (0)