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

[PANGOO-2594][BpkNavigationTabGroup]Fix BPK NavTabGroup Warning #3618

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions examples/bpk-component-navigation-tab-group/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const tabs: BpkNavigationTabGroupProps['tabs'] = [
];

const tabsWithIcon: BpkNavigationTabGroupProps['tabs'] = [
{ id: 'air', text: 'Flights', href: '/', icon: flightIcons, 'data-Cy':'flight-feature', 'data-Analytics':'flights' },
{ id: 'hotel', text: 'Hotels', href: '/hotel', icon: hotelIcons, 'data-Cy':'hotel-feature', 'data-Analytics':'hotels' },
{ id: 'car', text: 'Car hire', href: '/carhire', icon: carIcons, 'data-Cy':'carhire-feature', 'data-Analytics':'car hire' },
{ id: 'explore', text: 'Explore', href: '/Explore', icon: exploreIcons, 'data-Cy':'explore-feature', 'data-Analytics':'explore' },
{ id: 'air', text: 'Flights', href: '/', icon: flightIcons, 'data-cy':'flight-feature', 'data-analytics':'flights' },
{ id: 'hotel', text: 'Hotels', href: '/hotel', icon: hotelIcons, 'data-cy':'hotel-feature', 'data-analytics':'hotels' },
{ id: 'car', text: 'Car hire', href: '/carhire', icon: carIcons, 'data-cy':'carhire-feature', 'data-analytics':'car hire' },
{ id: 'explore', text: 'Explore', href: '/Explore', icon: exploreIcons, 'data-cy':'explore-feature', 'data-analytics':'explore' },
];

const tabsNoHref: BpkNavigationTabGroupProps['tabs'] = [
Expand Down Expand Up @@ -92,7 +92,6 @@ const SimpleCanvasDefault = () => (
onItemClick={() => {}}
selectedIndex={0}
type={NAVIGATION_TAB_GROUP_TYPES.CanvasDefault}
ariaLabel="Navigation tabs"
Copy link
Contributor

@amburrrshand amburrrshand Sep 26, 2024

Choose a reason for hiding this comment

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

Why did you decide to remove the ariaLabel?

Copy link
Contributor Author

@kerrie625 kerrie625 Sep 26, 2024

Choose a reason for hiding this comment

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

Thanks @amburrrshand .Not remove it, Just change ariaLabel as optional. And this example is used for test props without ariaLabel

Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning to make it optional?

Surely by doing this we are decreasing Accessibility for travellers?

Copy link
Contributor Author

@kerrie625 kerrie625 Sep 26, 2024

Choose a reason for hiding this comment

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

When checking header tabs on production, I found the navigation tabs did not include ariaLabel before. So I think it needs to change this ariaLabel to option. Is it reasonable for consumer decide to whether pass this ariaLabel?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, I think it's best practice for accessibility standards to not have it as optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@olliecurtis @amburrrshand Thank you for your advice. I have reverted the ariaLabel as required.

/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ export const NAVIGATION_TAB_GROUP_TYPES = {
export type NavigationTabGroupTypes =
(typeof NAVIGATION_TAB_GROUP_TYPES)[keyof typeof NAVIGATION_TAB_GROUP_TYPES];

type TabItem = {
type TabWrapItem = {
id: string;
text: string;
icon?: FunctionComponent<any> | null;
href?: string;
[rest: string]: any;
};

type TabItem = TabWrapItem & {
text: string;
icon?: FunctionComponent<any> | null;
};
export type Props = {
id: string;
tabs: TabItem[];
Expand All @@ -49,11 +52,11 @@ export type Props = {
*/
onItemClick: (e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>,tab: TabItem, index: number) => void;
selectedIndex: number;
ariaLabel: string;
ariaLabel?: string;
};

type TabWrapProps = {
tab: TabItem;
tab: TabWrapItem;
type: NavigationTabGroupTypes;
selected: boolean;
children: ReactElement;
Expand Down Expand Up @@ -120,11 +123,12 @@ const BpkNavigationTabGroup = ({
>
{tabs.map((tab, index) => {
const selected = index === selectedTab;
const Icon = tab.icon;
const {icon,text,...tabWrapItem} = tab;
const Icon = icon;
return (
<TabWrap
key={`index-${index.toString()}`}
tab={tab}
tab={tabWrapItem}
selected={selected}
onClick={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => handleButtonClick(e, tab, index)}
type={type}
Expand All @@ -142,7 +146,7 @@ const BpkNavigationTabGroup = ({
</span>
)}
<BpkText tagName="span" textStyle={TEXT_STYLES.label2}>
{tab.text}
{text}
</BpkText>
</>
</TabWrap>
Expand Down
Loading