@@ -448,6 +448,8 @@ function listItems($list, items, callback, options = {}) {
448448 const $valueText = $target . get ( ".value" ) ;
449449 const $checkbox = $target . get ( ".input-checkbox" ) ;
450450 const $trailingValueText = $target . get ( ".setting-trailing-value" ) ;
451+ const shouldUpdateInlineValue =
452+ $valueText && ! $valueText . classList . contains ( "setting-info" ) ;
451453 let res ;
452454 let shouldUpdateValue = false ;
453455
@@ -483,15 +485,60 @@ function listItems($list, items, callback, options = {}) {
483485
484486 if ( shouldUpdateValue ) {
485487 item . value = res ;
486- setValueText ( $valueText , res , valueText ?. bind ( item ) ) ;
487- setValueText ( $trailingValueText , res , valueText ?. bind ( item ) ) ;
488+ if ( options . valueInTail ) {
489+ setValueText ( $trailingValueText , res , valueText ?. bind ( item ) ) ;
490+ } else {
491+ syncInlineValueDisplay ( $target , item , useInfoAsDescription ) ;
492+ }
488493 setColor ( $target , res ) ;
489494 }
490495
491496 callback . call ( $target , key , item . value ) ;
492497 }
493498}
494499
500+ /**
501+ * Keeps the inline subtitle/value block in sync when a setting value changes.
502+ * @param {HTMLElement } $target
503+ * @param {ListItem } item
504+ * @param {boolean } useInfoAsDescription
505+ */
506+ function syncInlineValueDisplay ( $target , item , useInfoAsDescription ) {
507+ const subtitle = getSubtitleText ( item , useInfoAsDescription ) ;
508+ const showInfoAsSubtitle =
509+ item . checkbox !== undefined ||
510+ typeof item . value === "boolean" ||
511+ useInfoAsDescription ||
512+ ( item . value === undefined && item . info ) ;
513+ const hasSubtitle =
514+ subtitle !== undefined && subtitle !== null && subtitle !== "" ;
515+ let $valueText = $target . get ( ".value" ) ;
516+ const $container = $target . get ( ".container" ) ;
517+
518+ if ( ! $container ) return ;
519+
520+ if ( ! hasSubtitle ) {
521+ $valueText ?. remove ( ) ;
522+ $target . classList . remove ( "has-subtitle" ) ;
523+ $target . classList . add ( "compact" ) ;
524+ return ;
525+ }
526+
527+ if ( ! $valueText ) {
528+ $valueText = < small className = "value" > </ small > ;
529+ $container . append ( $valueText ) ;
530+ }
531+
532+ $valueText . classList . toggle ( "setting-info" , showInfoAsSubtitle ) ;
533+ setValueText (
534+ $valueText ,
535+ subtitle ,
536+ showInfoAsSubtitle ? null : item . valueText ?. bind ( item ) ,
537+ ) ;
538+ $target . classList . add ( "has-subtitle" ) ;
539+ $target . classList . remove ( "compact" ) ;
540+ }
541+
495542function getSubtitleText ( item , useInfoAsDescription ) {
496543 if ( useInfoAsDescription ) {
497544 return item . info ;
0 commit comments