@@ -253,15 +253,15 @@ export function updateElementsVisibilityForOptions(
253253
254254 if ( closeIndex === - 1 ) return ;
255255
256- // Check if any lines between open and close are visible option lines
256+ // Check if any lines between open and close are visible (non-marker lines)
257257 let hasVisibleIntegrations = false ;
258258 for ( let i = openIndex + 1 ; i < closeIndex ; i ++ ) {
259259 const line = allLines [ i ] ;
260- const isOption = line . dataset . onboardingOption ;
261260 const isHidden = line . classList . contains ( 'hidden' ) ;
262261 const isMarker = line . dataset . onboardingOptionHidden ;
263262
264- if ( isOption && ! isMarker && ! isHidden ) {
263+ // Count any visible non-marker line
264+ if ( ! isMarker && ! isHidden ) {
265265 hasVisibleIntegrations = true ;
266266 break ;
267267 }
@@ -270,6 +270,44 @@ export function updateElementsVisibilityForOptions(
270270 // Toggle visibility of both open and close lines
271271 openLine . classList . toggle ( 'hidden' , ! hasVisibleIntegrations ) ;
272272 allLines [ closeIndex ] . classList . toggle ( 'hidden' , ! hasVisibleIntegrations ) ;
273+
274+ // Hide empty lines adjacent to the wrapper when no integrations are visible
275+ if ( ! hasVisibleIntegrations ) {
276+ // Check line before open wrapper
277+ if ( openIndex > 0 ) {
278+ const prevLine = allLines [ openIndex - 1 ] ;
279+ const prevText = prevLine . textContent ?. trim ( ) ;
280+ if ( ! prevText || prevText === '' ) {
281+ prevLine . style . display = 'none' ;
282+ }
283+ }
284+
285+ // Check line after close wrapper
286+ if ( closeIndex < allLines . length - 1 ) {
287+ const nextLine = allLines [ closeIndex + 1 ] ;
288+ const nextText = nextLine . textContent ?. trim ( ) ;
289+ if ( ! nextText || nextText === '' ) {
290+ nextLine . style . display = 'none' ;
291+ }
292+ }
293+ } else {
294+ // Show empty lines when integrations are visible
295+ if ( openIndex > 0 ) {
296+ const prevLine = allLines [ openIndex - 1 ] ;
297+ const prevText = prevLine . textContent ?. trim ( ) ;
298+ if ( ! prevText || prevText === '' ) {
299+ prevLine . style . display = '' ;
300+ }
301+ }
302+
303+ if ( closeIndex < allLines . length - 1 ) {
304+ const nextLine = allLines [ closeIndex + 1 ] ;
305+ const nextText = nextLine . textContent ?. trim ( ) ;
306+ if ( ! nextText || nextText === '' ) {
307+ nextLine . style . display = '' ;
308+ }
309+ }
310+ }
273311 } ) ;
274312}
275313
0 commit comments