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

add default (= null) for classNames prop so it's optional for WizardTaskItem and CollapsibleBody #9157

Merged
merged 12 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions changelog/fix-9142-classname-optional-default-null
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Migrate WizardTaskItem and CollapsibleBody components to TypeScript, making the className prop optional.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import classNames from 'classnames';
import WizardTaskContext from './task/context';
import './collapsible-body.scss';

const CollapsibleBody = ( { className, ...restProps } ) => {
const CollapsibleBody: React.FC< React.HTMLAttributes< HTMLDivElement > > = ( {
className,
...restProps
} ) => {
const { isActive } = useContext( WizardTaskContext );

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ import { Icon, check } from '@wordpress/icons';
import WizardTaskContext from './task/context';
import './task-item.scss';

const WizardTaskItem = ( { children, title, index, className } ) => {
interface WizardTaskItemProps {
children: React.ReactNode;
title: string;
index: number;
className?: string;
}

const WizardTaskItem: React.FC< WizardTaskItemProps > = ( {
children,
title,
index,
className,
} ) => {
const { isCompleted, isActive } = useContext( WizardTaskContext );

return (
Expand All @@ -26,7 +38,7 @@ const WizardTaskItem = ( { children, title, index, className } ) => {
className="wcpay-wizard-task__headline"
// tabindex with value `-1` is necessary to programmatically set the focus
// on an element that is not interactive.
tabIndex="-1"
tabIndex={ -1 }
>
<div className="wcpay-wizard-task__icon-wrapper">
<div className="wcpay-wizard-task__icon-text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ import { Icon, check } from '@wordpress/icons';
import WizardTaskContext from '../../additional-methods-setup/wizard/task/context';
import './task-item.scss';

const WizardTaskItem = ( {
interface WizardTaskItemProps {
children: React.ReactNode;
title: string;
index: number;
visibleDescription: string;
className?: string;
}

const WizardTaskItem: React.FC< WizardTaskItemProps > = ( {
children,
title,
index,
className,
visibleDescription,
className,
} ) => {
const { isCompleted, isActive } = useContext( WizardTaskContext );

Expand All @@ -32,7 +40,7 @@ const WizardTaskItem = ( {
className="wcpay-wizard-task__headline"
// tabindex with value `-1` is necessary to programmatically set the focus
// on an element that is not interactive.
tabIndex="-1"
tabIndex={ -1 }
>
<div className="wcpay-wizard-task__icon-wrapper">
<div className="wcpay-wizard-task__icon-text">
Expand Down
3 changes: 1 addition & 2 deletions client/vat/form/tasks/company-data-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ export const CompanyDataTask = ( {
'Confirm your business details',
'woocommerce-payments'
) }
className={ null }
>
<CollapsibleBody className={ null }>
<CollapsibleBody>
<TextControl
label={ __( 'Business name', 'woocommerce-payments' ) }
value={ companyName }
Expand Down
3 changes: 1 addition & 2 deletions client/vat/form/tasks/vat-number-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export const VatNumberTask = ( {
),
getVatTaxIDName()
) }
className={ null }
>
<p className="wcpay-wizard-task__description-element">
{ __(
Expand All @@ -168,7 +167,7 @@ export const VatNumberTask = ( {
) }
</p>

<CollapsibleBody className={ null }>
<CollapsibleBody>
<CheckboxControl
checked={ isVatRegistered }
onChange={ setVatRegistered }
Expand Down
Loading