Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show search icon in edit mode if the search checkbox is on #1177

Merged
merged 4 commits into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions apis/nucleus/src/components/listbox/ListBoxInline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function ListBoxInline({ options, layout }) {
});

const shouldAutoFocus = searchVisible && search === 'toggle';
const showSearchIcon = searchEnabled !== false && search === 'toggle' && !constraints?.active;
const showSearchIcon = searchEnabled !== false && search === 'toggle';
const showSearchOrLockIcon = isLocked || showSearchIcon;
const showIcons = showSearchOrLockIcon || isDrillDown;
const iconsWidth = (showSearchOrLockIcon ? BUTTON_ICON_WIDTH : 0) + (isDrillDown ? ICON_WIDTH + ICON_PADDING : 0); // Drill-down icon needs padding right so there is space between the icon and the title
Expand All @@ -245,6 +245,29 @@ function ListBoxInline({ options, layout }) {
containerPadding = layoutOptions.layoutOrder === 'row' ? '2px 4px' : '2px 6px 2px 4px';
}

const searchIconComp = constraints?.active ? (
<SearchIcon title={translator.get('Listbox.Search')} size="large" style={{ fontSize: '12px', padding: '7px' }} />
) : (
<IconButton
onClick={onShowSearch}
tabIndex={-1}
title={translator.get('Listbox.Search')}
size="large"
disableRipple
data-testid="search-toggle-btn"
>
<SearchIcon style={{ fontSize: '12px' }} />
</IconButton>
);

const lockIconComp = selectDisabled() ? (
<Lock size="large" style={{ fontSize: '12px', padding: '7px' }} />
) : (
<IconButton title={translator.get('SelectionToolbar.ClickToUnlock')} tabIndex={-1} onClick={unlock} size="large">
<Lock disableRipple style={{ fontSize: '12px' }} />
</IconButton>
);

return (
<>
{toolbarDetachedOnly && <ActionsToolbar direction={direction} {...getActionToolbarProps(true)} />}
Expand Down Expand Up @@ -283,30 +306,7 @@ function ListBoxInline({ options, layout }) {
>
{showIcons && (
<Grid item sx={{ display: 'flex', alignItems: 'center', width: iconsWidth }}>
{isLocked ? (
<IconButton
title={translator.get('SelectionToolbar.ClickToUnlock')}
tabIndex={-1}
onClick={unlock}
disabled={selectDisabled()}
size="large"
>
<Lock disableRipple style={{ fontSize: '12px' }} />
</IconButton>
) : (
showSearchIcon && (
<IconButton
onClick={onShowSearch}
tabIndex={-1}
title={translator.get('Listbox.Search')}
size="large"
disableRipple
data-testid="search-toggle-btn"
>
<SearchIcon style={{ fontSize: '12px' }} />
</IconButton>
)
)}
{isLocked ? lockIconComp : showSearchIcon && searchIconComp}
{isDrillDown && (
<DrillDownIcon
tabIndex={-1}
Expand Down