@@ -20,6 +20,7 @@ import {
20
20
SHELLBAR_LOGO ,
21
21
SHELLBAR_COPILOT ,
22
22
SHELLBAR_NOTIFICATIONS ,
23
+ SHELLBAR_CANCEL ,
23
24
SHELLBAR_PROFILE ,
24
25
SHELLBAR_PRODUCTS ,
25
26
SHELLBAR_SEARCH ,
@@ -144,10 +145,6 @@ const metadata = {
144
145
type : Object ,
145
146
} ,
146
147
147
- _searchField : {
148
- type : Object ,
149
- } ,
150
-
151
148
_header : {
152
149
type : Object ,
153
150
} ,
@@ -164,6 +161,10 @@ const metadata = {
164
161
type : Boolean ,
165
162
noAttribute : true ,
166
163
} ,
164
+ _fullWidthSearch : {
165
+ type : Boolean ,
166
+ noAttribute : true ,
167
+ } ,
167
168
} ,
168
169
managedSlots : true ,
169
170
slots : /** @lends sap.ui.webcomponents.fiori.ShellBar.prototype */ {
@@ -376,7 +377,7 @@ class ShellBar extends UI5Element {
376
377
377
378
static get FIORI_3_BREAKPOINTS ( ) {
378
379
return [
379
- 559 ,
380
+ 599 ,
380
381
1023 ,
381
382
1439 ,
382
383
1919 ,
@@ -386,7 +387,7 @@ class ShellBar extends UI5Element {
386
387
387
388
static get FIORI_3_BREAKPOINTS_MAP ( ) {
388
389
return {
389
- "559 " : "S" ,
390
+ "599 " : "S" ,
390
391
"1023" : "M" ,
391
392
"1439" : "L" ,
392
393
"1919" : "XL" ,
@@ -429,10 +430,6 @@ class ShellBar extends UI5Element {
429
430
} ,
430
431
} ;
431
432
432
- this . _searchField = {
433
- left : 0 ,
434
- } ;
435
-
436
433
this . _handleResize = async event => {
437
434
await this . _getResponsivePopover ( ) ;
438
435
this . overflowPopover . close ( ) ;
@@ -527,15 +524,19 @@ class ShellBar extends UI5Element {
527
524
const isHidden = ( info . classes . indexOf ( "ui5-shellbar-hidden-button" ) !== - 1 ) ;
528
525
const isSet = info . classes . indexOf ( "ui5-shellbar-invisible-button" ) === - 1 ;
529
526
const isOverflowIcon = info . classes . indexOf ( "ui5-shellbar-overflow-button" ) !== - 1 ;
527
+ const isImageIcon = info . classes . indexOf ( "ui5-shellbar-image-button" ) !== - 1 ;
528
+ const shouldStayOnScreen = isOverflowIcon || ( isImageIcon && this . hasProfile ) ;
530
529
531
- return isHidden && isSet && ! isOverflowIcon ;
530
+ return isHidden && isSet && ! shouldStayOnScreen ;
532
531
} ) ;
533
532
534
533
this . _observeMenuItems ( ) ;
535
534
}
536
535
537
536
onAfterRendering ( ) {
538
537
this . _overflowActions ( ) ;
538
+
539
+ this . _fullWidthSearch = this . _showFullWidthSearch ;
539
540
}
540
541
541
542
/**
@@ -582,10 +583,16 @@ class ShellBar extends UI5Element {
582
583
583
584
_handleActionsOverflow ( ) {
584
585
const rightContainerRect = this . shadowRoot . querySelector ( ".ui5-shellbar-overflow-container-right" ) . getBoundingClientRect ( ) ;
585
- const icons = this . shadowRoot . querySelectorAll ( ".ui5-shellbar-button:not(.ui5-shellbar-overflow-button):not(.ui5-shellbar-invisible-button)" ) ;
586
+ let overflowSelector = ".ui5-shellbar-button:not(.ui5-shellbar-overflow-button):not(.ui5-shellbar-invisible-button)" ;
587
+
588
+ if ( this . showSearchField ) {
589
+ overflowSelector += ",.ui5-shellbar-search-field" ;
590
+ }
591
+
592
+ const elementsToOverflow = this . shadowRoot . querySelectorAll ( overflowSelector ) ;
586
593
const isRTL = this . effectiveDir === "rtl" ;
587
594
588
- let overflowCount = [ ] . filter . call ( icons , icon => {
595
+ let overflowCount = [ ] . filter . call ( elementsToOverflow , icon => {
589
596
const iconRect = icon . getBoundingClientRect ( ) ;
590
597
591
598
if ( isRTL ) {
@@ -597,7 +604,7 @@ class ShellBar extends UI5Element {
597
604
598
605
overflowCount = overflowCount . length ;
599
606
600
- const items = this . _getAllItems ( ! ! overflowCount ) ;
607
+ const items = this . _getAllItems ( ! ! overflowCount ) . filter ( item => item . show ) ;
601
608
602
609
const itemsByPriority = items . sort ( ( item1 , item2 ) => {
603
610
if ( item1 . priority > item2 . priority ) {
@@ -653,26 +660,7 @@ class ShellBar extends UI5Element {
653
660
return ;
654
661
}
655
662
656
- const searchField = this . shadowRoot . querySelector ( `#${ this . _id } -searchfield-wrapper` ) ;
657
- const triggeredByOverflow = event . target . tagName . toLowerCase ( ) === "ui5-li" ;
658
- const overflowButton = this . shadowRoot . querySelector ( ".ui5-shellbar-overflow-button" ) ;
659
- const overflowButtonRect = overflowButton . getBoundingClientRect ( ) ;
660
- const isRTL = this . effectiveDir === "rtl" ;
661
- let right = "" ;
662
-
663
- if ( isRTL ) {
664
- right = `${ ( triggeredByOverflow ? overflowButton . offsetLeft : event . target . offsetLeft ) + overflowButtonRect . width } px` ;
665
- } else {
666
- right = `calc(100% - ${ triggeredByOverflow ? overflowButton . offsetLeft : event . target . offsetLeft } px)` ;
667
- }
668
-
669
- this . _searchField = Object . assign ( { } , this . _searchField , {
670
- "right" : right ,
671
- } ) ;
672
-
673
-
674
- const inputSlot = searchField . children [ 0 ] ;
675
- const input = inputSlot && inputSlot . assignedNodes ( ) [ 0 ] ;
663
+ const input = this . searchField [ 0 ] ;
676
664
677
665
// update the state immediately
678
666
if ( input ) {
@@ -719,6 +707,10 @@ class ShellBar extends UI5Element {
719
707
} ) ;
720
708
}
721
709
710
+ _handleCancelButtonPress ( ) {
711
+ this . showSearchField = false ;
712
+ }
713
+
722
714
_handleProductSwitchPress ( event ) {
723
715
const buttonRef = this . shadowRoot . querySelector ( ".ui5-shellbar-button-product-switch" ) ;
724
716
@@ -744,6 +736,7 @@ class ShellBar extends UI5Element {
744
736
style : `order: ${ this . searchField . length ? 1 : - 10 } ` ,
745
737
id : `${ this . _id } -item-${ 1 } ` ,
746
738
press : this . _handleSearchIconPress . bind ( this ) ,
739
+ show : ! ! this . searchField . length ,
747
740
} ,
748
741
...this . items . map ( ( item , index ) => {
749
742
return {
@@ -893,10 +886,6 @@ class ShellBar extends UI5Element {
893
886
894
887
get styles ( ) {
895
888
return {
896
- searchField : {
897
- [ this . effectiveDir === "rtl" ? "left" : "right" ] : this . _searchField . right ,
898
- "top" : `${ parseInt ( this . _searchField . top ) } px` ,
899
- } ,
900
889
items : {
901
890
notification : {
902
891
"order" : this . isIconHidden ( "bell" ) ? "-1" : "3" ,
@@ -911,9 +900,24 @@ class ShellBar extends UI5Element {
911
900
"order" : this . isIconHidden ( "grid" ) ? "-1" : "6" ,
912
901
} ,
913
902
} ,
903
+ searchField : {
904
+ "display" : this . correctSearchFieldStyles ,
905
+ } ,
914
906
} ;
915
907
}
916
908
909
+ get correctSearchFieldStyles ( ) {
910
+ if ( this . showSearchField ) {
911
+ if ( this . _fullWidthSearch ) {
912
+ return "flex" ;
913
+ }
914
+
915
+ return "block" ;
916
+ }
917
+
918
+ return "none" ;
919
+ }
920
+
917
921
get customItemsInfo ( ) {
918
922
return this . _itemsInfo . filter ( itemInfo => ! ! itemInfo . custom ) ;
919
923
}
@@ -982,6 +986,17 @@ class ShellBar extends UI5Element {
982
986
return this . i18nBundle . getText ( SHELLBAR_NOTIFICATIONS , this . notificationCount ) ;
983
987
}
984
988
989
+ get _cancelBtnText ( ) {
990
+ return this . i18nBundle . getText ( SHELLBAR_CANCEL ) ;
991
+ }
992
+
993
+ get _showFullWidthSearch ( ) {
994
+ const size = this . _handleBarBreakpoints ( ) ;
995
+ const searchBtnHidden = ! ! this . shadowRoot . querySelector ( ".ui5-shellbar-search-button.ui5-shellbar-hidden-button" ) ;
996
+
997
+ return ( ( size === "S" ) || searchBtnHidden ) ;
998
+ }
999
+
985
1000
get _profileText ( ) {
986
1001
return this . i18nBundle . getText ( SHELLBAR_PROFILE ) ;
987
1002
}
0 commit comments