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

Fix #6939: Datatable fix row checkbox/radiobutton PT #6941

Merged
merged 1 commit into from
Jul 28, 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
22 changes: 8 additions & 14 deletions components/lib/column/column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
*/
import * as React from 'react';
import { FilterMatchMode } from '../api/api';
import { CheckboxPassThroughOptions } from '../checkbox/checkbox';
import { ComponentHooks } from '../componentbase/componentbase';
import { DataTablePassThroughOptions } from '../datatable/datatable';
import { PassThroughOptions } from '../passthrough';
import { RadioButtonPassThroughOptions } from '../radiobutton/radiobutton';
import { TooltipOptions } from '../tooltip/tooltipoptions';
import { IconType, PassThroughType } from '../utils/utils';

Expand Down Expand Up @@ -161,9 +163,9 @@ export interface ColumnPassThroughOptions {
*/
sortBadge?: ColumnPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Uses to pass attributes to the header checkbox's DOM element.
* Uses to pass attributes to the header checkbox's component.
*/
headerCheckbox?: ColumnPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
headerCheckbox?: CheckboxPassThroughOptions;
/**
* Uses to pass attributes to the column filter's DOM element.
*/
Expand Down Expand Up @@ -313,21 +315,13 @@ export interface ColumnPassThroughOptions {
*/
rowReorderIcon?: ColumnPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the row radiobutton wrapper's DOM element.
* Uses to pass attributes to the row radiobutton component.
*/
radioButton?: ColumnPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
rowRadioButton?: RadioButtonPassThroughOptions;
/**
* Uses to pass attributes to the row radiobutton input's DOM element.
* Uses to pass attributes to the row checkbox component.
*/
radioButtonInput?: ColumnPassThroughType<React.HTMLAttributes<HTMLInputElement>>;
/**
* Uses to pass attributes to the row radiobutton box's DOM element.
*/
radioButtonBox?: ColumnPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
/**
* Uses to pass attributes to the row radiobutton icon's DOM element.
*/
radioButtonIcon?: ColumnPassThroughType<React.HTMLAttributes<HTMLDivElement>>;
rowCheckbox?: CheckboxPassThroughOptions;
/**
* Used to manage all lifecycle hooks
* @see {@link ComponentHooks}
Expand Down
24 changes: 11 additions & 13 deletions components/lib/datatable/RowCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,17 @@ export const RowCheckbox = React.memo((props) => {
const checkIcon = IconUtils.getJSXIcon(icon, { ...checkboxIconProps }, { props });
const tabIndex = props.disabled ? null : '0';

const checkboxProps = mergeProps(
{
role: 'checkbox',
'aria-checked': props.checked,
tabIndex: tabIndex,
onChange: onChange,
'aria-label': props.ariaLabel,
checked: props.checked,
icon: checkIcon,
disabled: props.disabled
},
getColumnPTOptions('rowCheckbox')
);
const checkboxProps = mergeProps({
role: 'checkbox',
'aria-checked': props.checked,
tabIndex: tabIndex,
onChange: onChange,
'aria-label': props.ariaLabel,
checked: props.checked,
icon: checkIcon,
disabled: props.disabled,
pt: getColumnPTOptions('rowCheckbox')
});

return <Checkbox {...checkboxProps} />;
});
Expand Down
25 changes: 10 additions & 15 deletions components/lib/datatable/RowRadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,16 @@ export const RowRadioButton = React.memo((props) => {
}
};

const radioButtonProps = mergeProps(
{
role: 'radio',
'aria-checked': props.checked,
checked: props.checked,
disabled: props.disabled,
name: `${props.tableSelector}_dt_radio`,
onChange: onChange,
input: getColumnPTOptions('radiobuttoninput'),
box: getColumnPTOptions('radiobuttonbox'),
icon: getColumnPTOptions('radiobuttonicon'),
unstyled: props.unstyled
},
getColumnPTOptions('radiobutton')
);
const radioButtonProps = mergeProps({
role: 'radio',
'aria-checked': props.checked,
checked: props.checked,
disabled: props.disabled,
name: `${props.tableSelector}_dt_radio`,
onChange: onChange,
unstyled: props.unstyled,
pt: getColumnPTOptions('rowRadioButton')
});

return <RadioButton {...radioButtonProps} />;
});
Expand Down
Loading