From ce5e6b747907d59d208ee8362e6bddeeefbf6383 Mon Sep 17 00:00:00 2001 From: melloware Date: Sun, 28 Jul 2024 08:28:25 -0400 Subject: [PATCH] Fix #6939: Datatable fix row checkbox/radiobutton PT --- components/lib/column/column.d.ts | 22 +++++++------------ components/lib/datatable/RowCheckbox.js | 24 ++++++++++----------- components/lib/datatable/RowRadioButton.js | 25 +++++++++------------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/components/lib/column/column.d.ts b/components/lib/column/column.d.ts index 5b61ab74ae..bac78ab876 100644 --- a/components/lib/column/column.d.ts +++ b/components/lib/column/column.d.ts @@ -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'; @@ -161,9 +163,9 @@ export interface ColumnPassThroughOptions { */ sortBadge?: ColumnPassThroughType>; /** - * Uses to pass attributes to the header checkbox's DOM element. + * Uses to pass attributes to the header checkbox's component. */ - headerCheckbox?: ColumnPassThroughType>; + headerCheckbox?: CheckboxPassThroughOptions; /** * Uses to pass attributes to the column filter's DOM element. */ @@ -313,21 +315,13 @@ export interface ColumnPassThroughOptions { */ rowReorderIcon?: ColumnPassThroughType | React.HTMLAttributes>; /** - * Uses to pass attributes to the row radiobutton wrapper's DOM element. + * Uses to pass attributes to the row radiobutton component. */ - radioButton?: ColumnPassThroughType>; + 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>; - /** - * Uses to pass attributes to the row radiobutton box's DOM element. - */ - radioButtonBox?: ColumnPassThroughType>; - /** - * Uses to pass attributes to the row radiobutton icon's DOM element. - */ - radioButtonIcon?: ColumnPassThroughType>; + rowCheckbox?: CheckboxPassThroughOptions; /** * Used to manage all lifecycle hooks * @see {@link ComponentHooks} diff --git a/components/lib/datatable/RowCheckbox.js b/components/lib/datatable/RowCheckbox.js index 6c1e226c88..3864be4c4a 100644 --- a/components/lib/datatable/RowCheckbox.js +++ b/components/lib/datatable/RowCheckbox.js @@ -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 ; }); diff --git a/components/lib/datatable/RowRadioButton.js b/components/lib/datatable/RowRadioButton.js index 452664354c..c82f3fa411 100644 --- a/components/lib/datatable/RowRadioButton.js +++ b/components/lib/datatable/RowRadioButton.js @@ -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 ; });