diff --git a/packages/react-core/src/components/JumpLinks/JumpLinks.tsx b/packages/react-core/src/components/JumpLinks/JumpLinks.tsx index 345dcb2ef87..2b998f53543 100644 --- a/packages/react-core/src/components/JumpLinks/JumpLinks.tsx +++ b/packages/react-core/src/components/JumpLinks/JumpLinks.tsx @@ -162,7 +162,7 @@ export const JumpLinks: React.FunctionComponent = ({ const itemIndex = jumpLinkIndex++; const scrollItem = scrollItems[itemIndex]; return React.cloneElement(child as React.ReactElement, { - onClick(ev: React.MouseEvent) { + onClick(ev: React.MouseEvent) { isLinkClicked.current = true; // Items might have rendered after this component. Do a quick refresh. let newScrollItems; @@ -193,7 +193,7 @@ export const JumpLinks: React.FunctionComponent = ({ scrollableElement.scrollTo(0, newScrollItem.offsetTop - offset); } newScrollItem.focus(); - window.history.pushState('', '', ev.currentTarget.href); + window.history.pushState('', '', (ev.currentTarget as HTMLAnchorElement).href); ev.preventDefault(); setActiveIndex(itemIndex); } diff --git a/packages/react-core/src/components/JumpLinks/JumpLinksItem.tsx b/packages/react-core/src/components/JumpLinks/JumpLinksItem.tsx index f30e369545b..b2854661840 100644 --- a/packages/react-core/src/components/JumpLinks/JumpLinksItem.tsx +++ b/packages/react-core/src/components/JumpLinks/JumpLinksItem.tsx @@ -2,18 +2,19 @@ import * as React from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/JumpLinks/jump-links'; import { JumpLinksList } from './JumpLinksList'; +import { Button, ButtonVariant } from '../Button'; export interface JumpLinksItemProps extends Omit, 'onClick'> { /** Whether this item is active. Parent JumpLinks component sets this when passed a `scrollableSelector`. */ isActive?: boolean; /** Href for this link */ - href?: string; + href: string; /** Selector or HTMLElement to spy on */ node?: string | HTMLElement; /** Text to be rendered inside span */ children?: React.ReactNode; /** Click handler for anchor tag. Parent JumpLinks components tap into this. */ - onClick?: (ev: React.MouseEvent) => void; + onClick?: (ev: React.MouseEvent) => void; /** Class to add to li */ className?: string; } @@ -38,9 +39,11 @@ export const JumpLinksItem: React.FunctionComponent = ({ {...(isActive && { 'aria-current': 'location' })} {...props} > - - {children} - + + + {sublists} ); diff --git a/packages/react-core/src/components/JumpLinks/__tests__/JumpLinks.test.tsx b/packages/react-core/src/components/JumpLinks/__tests__/JumpLinks.test.tsx index 705d27a572b..f788d624916 100644 --- a/packages/react-core/src/components/JumpLinks/__tests__/JumpLinks.test.tsx +++ b/packages/react-core/src/components/JumpLinks/__tests__/JumpLinks.test.tsx @@ -7,9 +7,11 @@ import { JumpLinksList } from '../JumpLinksList'; test('simple jumplinks', () => { const { asFragment } = render( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); expect(asFragment()).toMatchSnapshot(); @@ -18,9 +20,11 @@ test('simple jumplinks', () => { test('jumplinks centered', () => { const { asFragment } = render( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); expect(asFragment()).toMatchSnapshot(); @@ -29,9 +33,11 @@ test('jumplinks centered', () => { test('jumplinks with label', () => { const { asFragment } = render( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); expect(asFragment()).toMatchSnapshot(); @@ -40,9 +46,11 @@ test('jumplinks with label', () => { test('vertical with label', () => { const { asFragment } = render( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); expect(asFragment()).toMatchSnapshot(); @@ -51,17 +59,19 @@ test('vertical with label', () => { test('expandable vertical with subsection', () => { const { asFragment } = render( - Inactive section - + Inactive section + Section with active subsection - Active subsection - Inactive subsection - Inactive subsection + + Active subsection + + Inactive subsection + Inactive subsection - Inactive section - Inactive section + Inactive section + Inactive section ); expect(asFragment()).toMatchSnapshot(); diff --git a/packages/react-core/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap b/packages/react-core/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap index 3db78b4a035..679663639af 100644 --- a/packages/react-core/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap +++ b/packages/react-core/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap @@ -62,28 +62,46 @@ exports[`expandable vertical with subsection 1`] = ` @@ -180,42 +243,69 @@ exports[`jumplinks centered 1`] = ` @@ -248,42 +338,69 @@ exports[`jumplinks with label 1`] = ` @@ -309,42 +426,69 @@ exports[`simple jumplinks 1`] = ` @@ -377,42 +521,69 @@ exports[`vertical with label 1`] = ` diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksBasic.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksBasic.tsx index c638b4efb25..dcd15c04453 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksBasic.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksBasic.tsx @@ -3,8 +3,10 @@ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core'; export const JumpLinksBasic: React.FunctionComponent = () => ( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksExpandableVerticalWithSubsection.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksExpandableVerticalWithSubsection.tsx index 40b45fd46dd..f05cf0f5c1d 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksExpandableVerticalWithSubsection.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksExpandableVerticalWithSubsection.tsx @@ -3,16 +3,18 @@ import { JumpLinks, JumpLinksItem, JumpLinksList } from '@patternfly/react-core' export const JumpLinksExpandableVerticalWithSubsection: React.FunctionComponent = () => ( - Inactive section - + Inactive section + Section with active subsection - Active subsection - Inactive subsection - Inactive subsection + + Active subsection + + Inactive subsection + Inactive subsection - Inactive section - Inactive section + Inactive section + Inactive section ); diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksVertical.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksVertical.tsx index a087d74cab3..78ad737986e 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksVertical.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksVertical.tsx @@ -3,8 +3,10 @@ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core'; export const JumpLinksVertical: React.FunctionComponent = () => ( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksVerticalWithLabel.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksVerticalWithLabel.tsx index 0fafa87c303..8026e51a791 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksVerticalWithLabel.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksVerticalWithLabel.tsx @@ -3,8 +3,10 @@ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core'; export const JumpLinksVerticalWithLabel: React.FunctionComponent = () => ( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithCenteredList.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithCenteredList.tsx index d317775f2de..01689f188b3 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithCenteredList.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithCenteredList.tsx @@ -3,8 +3,10 @@ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core'; export const JumpLinksWithCenteredList: React.FunctionComponent = () => ( - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section ); diff --git a/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithLabel.tsx b/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithLabel.tsx index 5f189a7896b..d716cab42bc 100644 --- a/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithLabel.tsx +++ b/packages/react-core/src/components/JumpLinks/examples/JumpLinksWithLabel.tsx @@ -4,14 +4,18 @@ import { JumpLinks, JumpLinksItem } from '@patternfly/react-core'; export const JumpLinksWithLabel: React.FunctionComponent = () => ( <> - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section - Inactive section - Active section - Inactive section + Inactive section + + Active section + + Inactive section );