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
commit fabc67eeb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 { t } from '@lingui/macro';
import useRequest from '../../util/useRequest';
import { SearchColumns, SortColumns } from '../../types';
import DataListToolbar from '../DataListToolbar';
import CheckboxListItem from '../CheckboxListItem';

View File

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

View File

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