Merge pull request #10279 from mabashian/8852-checkbox-list-item

Fixes bug where users were unable to click on text next to checkboxes/radios in modals

SUMMARY
link #8852
This should impact lists in modals where the user can select one or more of the rows.  They should now be able to click on the text/row in order to select.  Examples:

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

UI

Reviewed-by: Kersom <None>
Reviewed-by: Tiago Góes <tiago.goes2009@gmail.com>
This commit is contained in:
softwarefactory-project-zuul[bot]
2021-05-27 19:06:50 +00:00
committed by GitHub
3 changed files with 13 additions and 6 deletions

View File

@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { withRouter, useLocation } from 'react-router-dom'; import { withRouter, useLocation } from 'react-router-dom';
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import useRequest from '../../util/useRequest'; import useRequest from '../../util/useRequest';
import { SearchColumns, SortColumns } from '../../types'; import { SearchColumns, SortColumns } from '../../types';
import DataListToolbar from '../DataListToolbar'; import DataListToolbar from '../DataListToolbar';
import CheckboxListItem from '../CheckboxListItem'; import CheckboxListItem from '../CheckboxListItem';

View File

@@ -4,7 +4,6 @@ import { t } from '@lingui/macro';
import { Td, Tr } from '@patternfly/react-table'; import { Td, Tr } from '@patternfly/react-table';
const CheckboxListItem = ({ const CheckboxListItem = ({
isDisabled = false,
isRadio = false, isRadio = false,
isSelected = false, isSelected = false,
itemId, itemId,
@@ -16,15 +15,26 @@ const CheckboxListItem = ({
columns, columns,
item, item,
}) => { }) => {
const handleRowClick = () => {
if (isSelected && !isRadio) {
onDeselect(itemId);
} else {
onSelect(itemId);
}
};
return ( return (
<Tr ouiaId={`list-item-${itemId}`} id={`list-item-${itemId}`}> <Tr
ouiaId={`list-item-${itemId}`}
id={`list-item-${itemId}`}
onClick={handleRowClick}
>
<Td <Td
id={`check-action-item-${itemId}`} id={`check-action-item-${itemId}`}
select={{ select={{
rowIndex, rowIndex,
isSelected, isSelected,
onSelect: isSelected ? onDeselect : onSelect, onSelect: isSelected ? onDeselect : onSelect,
disable: isDisabled,
variant: isRadio ? 'radio' : 'checkbox', variant: isRadio ? 'radio' : 'checkbox',
}} }}
name={name} name={name}

View File

@@ -9,7 +9,6 @@ import {
oneOfType, oneOfType,
} from 'prop-types'; } from 'prop-types';
import styled from 'styled-components'; import styled from 'styled-components';
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import SelectedList from '../SelectedList'; import SelectedList from '../SelectedList';
import CheckboxListItem from '../CheckboxListItem'; import CheckboxListItem from '../CheckboxListItem';
@@ -41,7 +40,6 @@ function OptionsList({
deselectItem, deselectItem,
renderItemChip, renderItemChip,
isLoading, isLoading,
displayKey, displayKey,
}) { }) {
return ( return (