Skip to content

Commit

Permalink
Merge pull request #6320 from melloware/PR6288
Browse files Browse the repository at this point in the history
Fix #6288: MultiSelect focus checkbox on focus of list item
  • Loading branch information
gucal authored Apr 9, 2024
2 parents dd0fc90 + 4a7abc1 commit 8f380f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/lib/multiselect/MultiSelectItem.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import { Checkbox } from '../checkbox/Checkbox';
import { useMergeProps } from '../hooks/Hooks';
import { CheckIcon } from '../icons/check';
import { Ripple } from '../ripple/Ripple';
import { Checkbox } from '../checkbox/Checkbox';
import { IconUtils, ObjectUtils, classNames } from '../utils/Utils';

export const MultiSelectItem = React.memo((props) => {
const [focusedState, setFocusedState] = React.useState(false);
const checkboxRef = React.useRef(null);
const mergeProps = useMergeProps();
const { ptm, cx, isUnstyled } = props;

Expand All @@ -25,6 +26,7 @@ export const MultiSelectItem = React.memo((props) => {

const onFocus = (event) => {
setFocusedState(true);
checkboxRef?.current?.getInput().focus();
};

const onBlur = (event) => {
Expand Down Expand Up @@ -80,7 +82,7 @@ export const MultiSelectItem = React.memo((props) => {
return (
<li {...itemProps}>
<div {...checkboxContainerProps}>
<Checkbox checked={props.selected} icon={checkboxIcon} pt={ptm('checkbox')} unstyled={isUnstyled()} />
<Checkbox ref={checkboxRef} checked={props.selected} icon={checkboxIcon} pt={ptm('checkbox')} unstyled={isUnstyled()} />
</div>
<span>{content}</span>
<Ripple />
Expand Down

0 comments on commit 8f380f2

Please sign in to comment.