Skip to content

Commit 9f9979c

Browse files
authored
fix(VariantManagement): show search in view list popover if count is over 10 (#4999)
Fixes #4992
1 parent dbe2b58 commit 9f9979c

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

packages/main/src/components/VariantManagement/VariantManagement.cy.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,28 +253,28 @@ describe('VariantManagement', () => {
253253
<VariantManagement>
254254
<VariantItem>VariantItem 1</VariantItem>
255255
<VariantItem selected>VariantItem 2</VariantItem>
256-
{...new Array(8)
256+
{...new Array(9)
257257
.fill(':)')
258258
.map((_, index) => <VariantItem key={index + 3}>{`VariantItem ${index + 3}`}</VariantItem>)}
259259
</VariantManagement>
260260
);
261261
cy.get('[icon="navigation-down-arrow"]').click();
262-
cy.get('[ui5-li]').should('have.length', 10);
262+
cy.get('[ui5-li]').should('have.length', 11);
263263
cy.findByPlaceholderText('Search').typeIntoUi5Input('VariantItem 10');
264264
cy.get('[ui5-li]').should('have.length', 1).should('have.text', 'VariantItem 10');
265265
cy.get('[input-icon]').click();
266-
cy.get('[ui5-li]').should('have.length', 10);
266+
cy.get('[ui5-li]').should('have.length', 11);
267267

268268
cy.mount(
269269
<VariantManagement>
270270
{TwoVariantItems}
271-
{new Array(7).fill(':)').map((_, index) => (
271+
{new Array(8).fill(':)').map((_, index) => (
272272
<VariantItem key={index + 3}>{`VariantItem ${index + 3}`}</VariantItem>
273273
))}
274274
</VariantManagement>
275275
);
276276
cy.get('[icon="navigation-down-arrow"]').click();
277-
cy.get('[ui5-li]').should('have.length', 9);
277+
cy.get('[ui5-li]').should('have.length', 10);
278278
cy.findByPlaceholderText('Search', { timeout: 200 }).should('not.exist');
279279
});
280280

packages/main/src/components/VariantManagement/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,11 @@ const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>
279279
const popoverRef = useRef<ResponsivePopoverDomRef>(null);
280280

281281
const [safeChildren, setSafeChildren] = useState(Children.toArray(children));
282-
const [showInput, setShowInput] = useState(safeChildren.length > 9);
283282

284283
useEffect(() => {
285284
setSafeChildren(Children.toArray(children));
286285
}, [children]);
287286

288-
useEffect(() => {
289-
if (safeChildren.length > 9) {
290-
setShowInput(true);
291-
} else {
292-
setShowInput(false);
293-
}
294-
}, [safeChildren.length]);
295-
296287
const [manageViewsDialogOpen, setManageViewsDialogOpen] = useState(false);
297288
const [saveAsDialogOpen, setSaveAsDialogOpen] = useState(false);
298289
const [selectedVariant, setSelectedVariant] = useState<SelectedVariant | undefined>(() => {
@@ -449,6 +440,7 @@ const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>
449440
}, [showOnlyFavorites, safeChildren]);
450441

451442
const safeChildrenWithFavorites = favoriteChildren ?? safeChildren;
443+
const showInput = safeChildrenWithFavorites.length > 10;
452444

453445
const [filteredChildren, setFilteredChildren] = useState(undefined);
454446
const [searchValue, setSearchValue] = useState('');

0 commit comments

Comments
 (0)