Skip to content

Commit f370b56

Browse files
authored
fix: dropdown checkbox click area (#1215)
1 parent 95ac098 commit f370b56

File tree

2 files changed

+47
-42
lines changed

2 files changed

+47
-42
lines changed

src/search-manager/FilterByBlockType.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ const FilterByBlockType: React.FC<Record<never, never>> = () => {
8181
<Menu className="block-type-refinement-menu" style={{ boxShadow: 'none' }}>
8282
{
8383
Object.entries(sortedBlockTypes).map(([blockType, count]) => (
84-
<MenuItem
85-
key={blockType}
86-
as={Form.Checkbox}
87-
value={blockType}
88-
checked={blockTypesFilter.includes(blockType)}
89-
onChange={handleCheckboxChange}
90-
>
91-
<BlockTypeLabel type={blockType} />{' '}
92-
<Badge variant="light" pill>{count}</Badge>
93-
</MenuItem>
84+
<label key={blockType} className="d-inline">
85+
<MenuItem
86+
as={Form.Checkbox}
87+
value={blockType}
88+
checked={blockTypesFilter.includes(blockType)}
89+
onChange={handleCheckboxChange}
90+
>
91+
<BlockTypeLabel type={blockType} />{' '}
92+
<Badge variant="light" pill>{count}</Badge>
93+
</MenuItem>
94+
</label>
9495
))
9596
}
9697
{

src/search-manager/FilterByTags.tsx

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,43 @@ const TagMenuItem: React.FC<{
4949
const randomNumber = React.useMemo(() => Math.floor(Math.random() * 1000), []);
5050
const checkboxId = tagPath.replace(/[\W]/g, '_') + randomNumber;
5151

52+
const expandChildrenClick = React.useCallback((e) => {
53+
e.preventDefault();
54+
onToggleChildren?.(tagPath);
55+
}, [onToggleChildren, tagPath]);
56+
5257
return (
53-
<div className="pgn__menu-item pgn__form-checkbox tag-toggle-item" role="group">
54-
<input
55-
type="checkbox"
56-
id={checkboxId}
57-
checked={isChecked}
58-
onChange={onClickCheckbox}
59-
className="pgn__form-checkbox-input flex-shrink-0"
60-
/>
61-
<label htmlFor={checkboxId} className="flex-shrink-1 mb-0">
62-
{label}{' '}
63-
<Badge variant="light" pill>{tagCount}</Badge>
64-
</label>
65-
{
66-
hasChildren
67-
? (
68-
<IconButton
69-
src={isExpanded ? ArrowDropUp : ArrowDropDown}
70-
iconAs={Icon}
71-
alt={
72-
intl.formatMessage(
73-
isExpanded ? messages.childTagsCollapse : messages.childTagsExpand,
74-
{ tagName: label },
75-
)
76-
}
77-
onClick={() => onToggleChildren?.(tagPath)}
78-
variant="primary"
79-
size="sm"
80-
/>
81-
) : null
82-
}
83-
</div>
58+
<label className="d-inline">
59+
<div className="pgn__menu-item pgn__form-checkbox tag-toggle-item" role="group">
60+
<input
61+
type="checkbox"
62+
id={checkboxId}
63+
checked={isChecked}
64+
onChange={onClickCheckbox}
65+
className="pgn__form-checkbox-input flex-shrink-0"
66+
/>
67+
{label}
68+
<Badge variant="light" pill className="ml-1">{tagCount}</Badge>
69+
{
70+
hasChildren
71+
? (
72+
<IconButton
73+
src={isExpanded ? ArrowDropUp : ArrowDropDown}
74+
iconAs={Icon}
75+
alt={
76+
intl.formatMessage(
77+
isExpanded ? messages.childTagsCollapse : messages.childTagsExpand,
78+
{ tagName: label },
79+
)
80+
}
81+
onClick={expandChildrenClick}
82+
variant="primary"
83+
size="sm"
84+
/>
85+
) : null
86+
}
87+
</div>
88+
</label>
8489
);
8590
};
8691

@@ -125,7 +130,6 @@ const TagOptions: React.FC<{
125130
return (
126131
<React.Fragment key={tagName}>
127132
<TagMenuItem
128-
key={tagName}
129133
label={tagName}
130134
tagCount={t.tagCount}
131135
tagPath={tagPath}

0 commit comments

Comments
 (0)