@@ -48,6 +48,8 @@ if (!window.IS_STORYBOOK) {
48
48
* @property {boolean } pinnedTabsGridView - Whether to show pinned tabs in a grid view
49
49
* @property {Array } tabItems - Items to show in the tab list
50
50
* @property {string } searchQuery - The query string to highlight, if provided.
51
+ * @property {string } secondaryActionClass - The class used to style the secondary action element
52
+ * @property {string } tertiaryActionClass - The class used to style the tertiary action element
51
53
*/
52
54
export default class FxviewTabList extends MozLitElement {
53
55
constructor ( ) {
@@ -79,6 +81,8 @@ export default class FxviewTabList extends MozLitElement {
79
81
tabItems : { type : Array } ,
80
82
updatesPaused : { type : Boolean } ,
81
83
searchQuery : { type : String } ,
84
+ secondaryActionClass : { type : String } ,
85
+ tertiaryActionClass : { type : String } ,
82
86
} ;
83
87
84
88
static queries = {
@@ -244,8 +248,16 @@ export default class FxviewTabList extends MozLitElement {
244
248
this . currentActiveElementId === "fxview-tab-row-main"
245
249
) {
246
250
this . currentActiveElementId = fxviewTabRow . focusMediaButton ( ) ;
247
- } else {
248
- this . currentActiveElementId = fxviewTabRow . focusButton ( ) ;
251
+ } else if (
252
+ this . currentActiveElementId === "fxview-tab-row-media-button" ||
253
+ this . currentActiveElementId === "fxview-tab-row-main"
254
+ ) {
255
+ this . currentActiveElementId = fxviewTabRow . focusSecondaryButton ( ) ;
256
+ } else if (
257
+ fxviewTabRow . tertiaryButtonEl &&
258
+ this . currentActiveElementId === "fxview-tab-row-secondary-button"
259
+ ) {
260
+ this . currentActiveElementId = fxviewTabRow . focusTertiaryButton ( ) ;
249
261
}
250
262
}
251
263
@@ -257,6 +269,10 @@ export default class FxviewTabList extends MozLitElement {
257
269
this . activeIndex === this . pinnedTabs . length ) )
258
270
) {
259
271
this . focusPrevRow ( ) ;
272
+ } else if (
273
+ this . currentActiveElementId === "fxview-tab-row-tertiary-button"
274
+ ) {
275
+ this . currentActiveElementId = fxviewTabRow . focusSecondaryButton ( ) ;
260
276
} else if (
261
277
( fxviewTabRow . indicators ?. includes ( "soundplaying" ) ||
262
278
fxviewTabRow . indicators ?. includes ( "muted" ) ) &&
@@ -354,6 +370,10 @@ export default class FxviewTabList extends MozLitElement {
354
370
: "listitem" }
355
371
.secondaryL10nId=${ tabItem . secondaryL10nId }
356
372
.secondaryL10nArgs=${ ifDefined ( tabItem . secondaryL10nArgs ) }
373
+ .tertiaryL10nId=${ ifDefined ( tabItem . tertiaryL10nId ) }
374
+ .tertiaryL10nArgs=${ ifDefined ( tabItem . tertiaryL10nArgs ) }
375
+ .secondaryActionClass=${ this . secondaryActionClass }
376
+ .tertiaryActionClass=${ ifDefined ( this . tertiaryActionClass ) }
357
377
.sourceClosedId=${ ifDefined ( tabItem . sourceClosedId ) }
358
378
.sourceWindowId=${ ifDefined ( tabItem . sourceWindowId ) }
359
379
.closedId=${ ifDefined ( tabItem . closedId || tabItem . closedId ) }
@@ -456,6 +476,10 @@ customElements.define("fxview-tab-list", FxviewTabList);
456
476
* @property {string } primaryL10nArgs - The l10n args used for the primary action element
457
477
* @property {string } secondaryL10nId - The l10n id used for the secondary action button
458
478
* @property {string } secondaryL10nArgs - The l10n args used for the secondary action element
479
+ * @property {string } secondaryActionClass - The class used to style the secondary action element
480
+ * @property {string } tertiaryL10nId - The l10n id used for the tertiary action button
481
+ * @property {string } tertiaryL10nArgs - The l10n args used for the tertiary action element
482
+ * @property {string } tertiaryActionClass - The class used to style the tertiary action element
459
483
* @property {object } tabElement - The MozTabbrowserTab element for the tab item.
460
484
* @property {number } time - The timestamp for when the tab was last accessed.
461
485
* @property {string } title - The title for the tab item.
@@ -484,6 +508,10 @@ export class FxviewTabRow extends MozLitElement {
484
508
primaryL10nArgs : { type : String } ,
485
509
secondaryL10nId : { type : String } ,
486
510
secondaryL10nArgs : { type : String } ,
511
+ secondaryActionClass : { type : String } ,
512
+ tertiaryL10nId : { type : String } ,
513
+ tertiaryL10nArgs : { type : String } ,
514
+ tertiaryActionClass : { type : String } ,
487
515
closedId : { type : Number } ,
488
516
sourceClosedId : { type : Number } ,
489
517
sourceWindowId : { type : String } ,
@@ -497,7 +525,8 @@ export class FxviewTabRow extends MozLitElement {
497
525
498
526
static queries = {
499
527
mainEl : "#fxview-tab-row-main" ,
500
- buttonEl : "#fxview-tab-row-secondary-button:not([hidden])" ,
528
+ secondaryButtonEl : "#fxview-tab-row-secondary-button:not([hidden])" ,
529
+ tertiaryButtonEl : "#fxview-tab-row-tertiary-button" ,
501
530
mediaButtonEl : "#fxview-tab-row-media-button" ,
502
531
pinnedTabButtonEl : "button#fxview-tab-row-main" ,
503
532
} ;
@@ -536,9 +565,14 @@ export class FxviewTabRow extends MozLitElement {
536
565
this . currentFocusable . focus ( ) ;
537
566
}
538
567
539
- focusButton ( ) {
540
- this . buttonEl . focus ( ) ;
541
- return this . buttonEl . id ;
568
+ focusSecondaryButton ( ) {
569
+ this . secondaryButtonEl . focus ( ) ;
570
+ return this . secondaryButtonEl . id ;
571
+ }
572
+
573
+ focusTertiaryButton ( ) {
574
+ this . tertiaryButtonEl . focus ( ) ;
575
+ return this . tertiaryButtonEl . id ;
542
576
}
543
577
544
578
focusMediaButton ( ) {
@@ -667,6 +701,23 @@ export class FxviewTabRow extends MozLitElement {
667
701
}
668
702
}
669
703
704
+ tertiaryActionHandler ( event ) {
705
+ if (
706
+ ( event . type == "click" && event . detail && ! event . altKey ) ||
707
+ // detail=0 is from keyboard
708
+ ( event . type == "click" && ! event . detail )
709
+ ) {
710
+ event . preventDefault ( ) ;
711
+ this . dispatchEvent (
712
+ new CustomEvent ( "fxview-tab-list-tertiary-action" , {
713
+ bubbles : true ,
714
+ composed : true ,
715
+ detail : { originalEvent : event , item : this } ,
716
+ } )
717
+ ) ;
718
+ }
719
+ }
720
+
670
721
muteOrUnmuteTab ( ) {
671
722
this . tabElement . toggleMuteAudio ( ) ;
672
723
}
@@ -838,9 +889,14 @@ export class FxviewTabRow extends MozLitElement {
838
889
${ when (
839
890
this . secondaryL10nId && this . secondaryActionHandler ,
840
891
( ) => html `< button
841
- class ="fxview-tab-row-button ghost-button icon-button semi-transparent "
892
+ class =${ classMap ( {
893
+ "fxview-tab-row-button" : true ,
894
+ "ghost-button" : true ,
895
+ "icon-button" : true ,
896
+ "semi-transparent" : true ,
897
+ [ this . secondaryActionClass ] : this . secondaryActionClass ,
898
+ } ) }
842
899
id ="fxview-tab-row-secondary-button"
843
- part ="secondary-button "
844
900
data-l10n-id=${ this . secondaryL10nId }
845
901
data-l10n-args=${ ifDefined ( this . secondaryL10nArgs ) }
846
902
aria-haspopup=${ ifDefined ( this . hasPopup ) }
@@ -877,6 +933,27 @@ export class FxviewTabRow extends MozLitElement {
877
933
this . #pinnedTabItemTemplate. bind ( this ) ,
878
934
this . #unpinnedTabItemTemplate. bind ( this )
879
935
) }
936
+ ${ when (
937
+ this . tertiaryL10nId && this . tertiaryActionHandler ,
938
+ ( ) => html `< button
939
+ class =${ classMap ( {
940
+ "fxview-tab-row-button" : true ,
941
+ "ghost-button" : true ,
942
+ "icon-button" : true ,
943
+ "semi-transparent" : true ,
944
+ [ this . tertiaryActionClass ] : this . tertiaryActionClass ,
945
+ } ) }
946
+ id ="fxview-tab-row-tertiary-button"
947
+ data-l10n-id=${ this . tertiaryL10nId }
948
+ data-l10n-args=${ ifDefined ( this . tertiaryL10nArgs ) }
949
+ aria-haspopup=${ ifDefined ( this . hasPopup ) }
950
+ @click=${ this . tertiaryActionHandler }
951
+ tabindex="${ this . active &&
952
+ this . currentActiveElementId === "fxview-tab-row-tertiary-button"
953
+ ? "0"
954
+ : "-1" } "
955
+ > </ button > `
956
+ ) }
880
957
` ;
881
958
}
882
959
0 commit comments