File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 1-
21import { LitElement , html , type TemplateResult } from 'lit' ;
32import { customElement } from 'lit/decorators/custom-element.js' ;
43import { property } from 'lit/decorators/property.js' ;
@@ -23,10 +22,6 @@ export class PfLabelGroupExpandEvent extends Event {
2322 }
2423}
2524
26- /**
27- * Regex used to replace the `${remaining}` variable in collapsed text.
28- */
29- const REMAINING_RE = / \$ \{ \s * r e m a i n i n g \s * \} / g;
3025
3126/**
3227 * A **label group** is a collection of labels that can be grouped by category
@@ -236,14 +231,24 @@ export class PfLabelGroup extends LitElement {
236231 } ) ;
237232
238233 const rem = Math . max ( 0 , labels . length - this . numLabels ) ;
239- this . _overflowText = rem < 1 ?
240- ''
241- : this . open ?
242- this . expandedText
243- : this . collapsedText . replace ( REMAINING_RE , rem . toString ( ) ) ;
244-
245- if ( rem < 1 && this . open ) {
246- this . open = false ;
234+
235+ if ( rem < 1 ) {
236+ this . _overflowText = '' ;
237+ if ( this . open ) {
238+ this . open = false ;
239+ }
240+ } else {
241+ const placeholderMatch = this . collapsedText . match ( / \$ \{ .* ?\} / ) ;
242+ if ( placeholderMatch ) {
243+ const [ placeholder ] = placeholderMatch ;
244+ this . _overflowText = this . collapsedText . replace ( placeholder , rem . toString ( ) ) ;
245+ } else {
246+ this . _overflowText = this . collapsedText ;
247+ }
248+
249+ if ( this . open ) {
250+ this . _overflowText = this . expandedText ;
251+ }
247252 }
248253 }
249254}
You can’t perform that action at this time.
0 commit comments