File tree Expand file tree Collapse file tree 3 files changed +69
-1
lines changed
Expand file tree Collapse file tree 3 files changed +69
-1
lines changed Original file line number Diff line number Diff line change 1+ import Breadcrumbs from "../../src/Breadcrumbs.js" ;
2+ import BreadcrumbsItem from "../../src/BreadcrumbsItem.js" ;
3+
4+ describe ( "Breadcrumbs mobile behavior" , ( ) => {
5+ before ( ( ) => {
6+ cy . ui5SimulateDevice ( "phone" ) ;
7+ } ) ;
8+
9+ it ( "displays all items in the popover on mobile" , ( ) => {
10+ const breadcrumbItems = [
11+ "Products" ,
12+ "Categories" ,
13+ "Laptops" ,
14+ "Gaming Laptops" ,
15+ "XPS Pro"
16+ ] ;
17+
18+ cy . mount (
19+ < Breadcrumbs >
20+ { breadcrumbItems . map ( ( item , index ) => (
21+ < BreadcrumbsItem key = { index } href = { `#${ item } ` } > { item } </ BreadcrumbsItem >
22+ ) ) }
23+ </ Breadcrumbs >
24+ ) ;
25+
26+ // Open the overflow popover by clicking on the dropdown arrow within shadow DOM
27+ cy . get ( "ui5-breadcrumbs" )
28+ . shadow ( )
29+ . find ( ".ui5-breadcrumbs-dropdown-arrow-link-wrapper ui5-link" )
30+ . click ( ) ;
31+
32+ // Wait for the popover to be fully open
33+ cy . get ( "ui5-breadcrumbs" )
34+ . shadow ( )
35+ . find ( "ui5-responsive-popover" )
36+ . shadow ( )
37+ . find ( "ui5-dialog" )
38+ . should ( "be.visible" ) ;
39+
40+ // Verify that all items are displayed in the popover
41+ cy . get ( "ui5-breadcrumbs" )
42+ . shadow ( )
43+ . find ( "ui5-responsive-popover ui5-list ui5-li" )
44+ . should ( "have.length" , breadcrumbItems . length ) ;
45+
46+ // Verify the items are in the correct order (reversed)
47+ cy . get ( "ui5-breadcrumbs" )
48+ . shadow ( )
49+ . find ( "ui5-responsive-popover ui5-list ui5-li" )
50+ . eq ( 0 )
51+ . should ( "contain.text" , breadcrumbItems [ breadcrumbItems . length - 1 ] ) ;
52+ } ) ;
53+ } ) ;
Original file line number Diff line number Diff line change @@ -554,6 +554,16 @@ class Breadcrumbs extends UI5Element {
554554 . reverse ( ) ;
555555 }
556556
557+ /**
558+ * Returns all items that should be displayed in the popover on mobile devices
559+ * @private
560+ */
561+ get _mobilePopoverItems ( ) {
562+ return this . _getItems ( )
563+ . filter ( item => this . _isItemVisible ( item ) )
564+ . reverse ( ) ;
565+ }
566+
557567 /**
558568 * Getter for the list of abstract breadcrumb items to be rendered as links outside the overflow
559569 */
Original file line number Diff line number Diff line change 1+ import { isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
12import type Breadcrumbs from "./Breadcrumbs.js" ;
23import Button from "./Button.js" ;
34import List from "./List.js" ;
45import ListItemStandard from "./ListItemStandard.js" ;
56import ResponsivePopover from "./ResponsivePopover.js" ;
67
78export default function BreadcrumbsPopoverTemplate ( this : Breadcrumbs ) {
9+ const itemsToDisplay = isPhone ( )
10+ ? this . _mobilePopoverItems
11+ : this . _overflowItemsData ;
12+
813 return (
914 < ResponsivePopover
1015 class = "ui5-breadcrumbs-popover"
@@ -21,7 +26,7 @@ export default function BreadcrumbsPopoverTemplate(this: Breadcrumbs) {
2126 separators = "None"
2227 onSelectionChange = { this . _onOverflowListItemSelect }
2328 >
24- { this . _overflowItemsData . map ( item =>
29+ { itemsToDisplay . map ( item =>
2530 < ListItemStandard
2631 id = { `${ item . _id } -li` }
2732 accessibleName = { item . accessibleName }
You can’t perform that action at this time.
0 commit comments