@@ -346,8 +346,9 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
346346 }
347347 }
348348
349+ // Store background-color for active tabs to use in border CSS.
350+ $ activebackgroundcolor = null ;
349351 foreach ($ styles as $ key => $ value ) {
350-
351352 // If exist a unit for the rule, apply it.
352353 if (isset ($ units [$ key ])) {
353354 $ value = $ value . $ units [$ key ];
@@ -356,6 +357,11 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
356357 $ value = $ value . 'px ' ;
357358 }
358359
360+ // Capture background-color from any type that has it.
361+ if ($ key === 'background-color ' ) {
362+ $ activebackgroundcolor = $ value ;
363+ }
364+
359365 if ($ key == 'others ' ) {
360366 $ onecss .= $ value . '; ' ;
361367 } else {
@@ -364,6 +370,23 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
364370 }
365371
366372 $ onecss .= '} ' ;
373+
374+ // Add border CSS for .format_onetopic-tabs when this tab is active.
375+ // Apply the border to the tabs container when this specific tab is active.
376+ // Only generate CSS if a background color is defined.
377+ if (!empty ($ activebackgroundcolor ) && ($ type === 'active ' || $ type === 'default ' )) {
378+ $ onecss .= '#tabs-tree-start:has(#onetabid- ' . $ thissection ->id . ' a.nav-link.active) ' ;
379+ $ onecss .= '.format_onetopic-tabs { ' ;
380+ $ onecss .= 'border-bottom: 2px solid ' . $ activebackgroundcolor . ' !important; ' ;
381+ $ onecss .= 'padding-bottom: 1px; ' ;
382+ $ onecss .= '} ' ;
383+ $ onecss .= '#onetabid- ' . $ thissection ->id . ' .nav-link.active { border-color: ' . $ activebackgroundcolor . '; } ' ;
384+ $ onecss .= '#tabs-tree-start.verticaltabs .tabs-wrapper ' ;
385+ $ onecss .= ':has(#onetabid- ' . $ thissection ->id . ' a.nav-link.active) ' ;
386+ $ onecss .= '.format_onetopic-tabs { ' ;
387+ $ onecss .= 'border-bottom: none !important; ' ;
388+ $ onecss .= '} ' ;
389+ }
367390 }
368391
369392 // Clean the CSS for html tags.
0 commit comments