salesforce / design-system-react

Salesforce Lightning Design System for React
https://design-system-react-site.herokuapp.com/
BSD 3-Clause "New" or "Revised" License
918 stars 416 forks source link

add support for disabling data table selection (checkbox/radio) #3126

Closed meizibupt closed 1 year ago

meizibupt commented 1 year ago

Fixes #3125

Additional description

add option to disable radio/checkbox for datatable image image


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request

REVIEWER checklist (do not remove)

interactivellama commented 1 year ago

@meizibupt I'm going to look at this a little more later tonight, but when I pulled it down and used it. The main issue I'm seeing is that Nav to Edit mode and try to set focus on the disabled item. To reproduce, navigate with the arrow keys and then press enter. Focus visually disappears/gets lost.

I would recommend disabling switching to edit mode, essentially ignoring the switch to edit mode

interactivellama commented 1 year ago

Demo: 2023-08-10 17 39 45

meizibupt commented 1 year ago

@meizibupt I'm going to look at this a little more later tonight, but when I pulled it down and used it. The main issue I'm seeing is that Nav to Edit mode and try to set focus on the disabled item. To reproduce, navigate with the arrow keys and then press enter. Focus visually disappears/gets lost.

I would recommend disabling switching to edit mode, essentially ignoring the switch to edit mode

thanks for reviewing. can you be more specific. what do you mean by disabling edit mode? do you mean disallowing navigating to the disabled checkbox?

interactivellama commented 1 year ago

Yes, as in ignore the enter key if the child is disabled which is what is done when the content is only text in a cell.

Please check me on this, but I believe returning a normal disabled <Checkbox> instead of <InteractiveCheckbox> here https://github.com/salesforce/design-system-react/blob/master/components/data-table/private/row.jsx#L145 would disable the focus and treat it as non-actionable / non-editable.

Same with Radio here https://github.com/salesforce/design-system-react/blob/master/components/data-table/private/row.jsx#L145

interactivellama commented 1 year ago

Great addition! @meizibupt