fix: skip tab bar for single-block form-content layout
When form-content layout has only one entity type (e.g., just Products or just Materials), the tab bar with a single tab looks broken. Now: - Single block: no tab bar, no collapse toggle, content shown directly - Multi block: tab bar with collapse toggle, collapsed by default (unchanged) - Reverts previous collapsed default change (was wrong approach) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -345,13 +345,16 @@ class EntitySelectorRenderer
|
||||
{
|
||||
$requiredClass = !empty($config['required']) ? ' trait-required' : '';
|
||||
$singleModeClass = $globalMode === 'single' ? ' single-mode' : '';
|
||||
$isSingleBlock = count($enabledBlocks) <= 1;
|
||||
|
||||
// Check if blocks collapsed by default (default: false — show widget content immediately)
|
||||
$collapsed = isset($config['collapsed']) ? $config['collapsed'] : false;
|
||||
// For single-block selectors: no tab bar, always show content directly
|
||||
// For multi-block selectors: show tab bar, collapsed by default
|
||||
$collapsed = $isSingleBlock ? false : (isset($config['collapsed']) ? $config['collapsed'] : true);
|
||||
$collapsedClass = $collapsed ? ' blocks-collapsed' : '';
|
||||
$singleBlockClass = $isSingleBlock ? ' single-block' : '';
|
||||
|
||||
// Entity selector container (without form-group wrapper, without header)
|
||||
$html = '<div class="condition-trait target-conditions-trait layout-form-group' . $singleModeClass . $requiredClass . $collapsedClass . '"';
|
||||
$html = '<div class="condition-trait target-conditions-trait layout-form-group' . $singleModeClass . $requiredClass . $collapsedClass . $singleBlockClass . '"';
|
||||
$html .= ' data-entity-selector-id="' . $this->escapeAttr($config['id']) . '"';
|
||||
$html .= ' data-mode="' . $this->escapeAttr($globalMode) . '"';
|
||||
if (!empty($config['required'])) {
|
||||
@@ -363,27 +366,29 @@ class EntitySelectorRenderer
|
||||
}
|
||||
$html .= ' data-config=\'' . $jsConfigJson . '\'>';
|
||||
|
||||
// Tabs row (always visible) with collapse toggle
|
||||
$html .= '<div class="entity-selector-tabs-row">';
|
||||
$html .= $this->renderTabs($enabledBlocks, $activeBlock, $savedData, $config);
|
||||
if ($isSingleBlock) {
|
||||
// Single block: no tab bar, no collapse toggle — show content directly
|
||||
$html .= '<div class="entity-selector-blocks-content">';
|
||||
$html .= $this->renderBlocks($enabledBlocks, $activeBlock, $savedData, $config, $globalMode);
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
// Multiple blocks: show tab bar with collapse toggle
|
||||
$html .= '<div class="entity-selector-tabs-row">';
|
||||
$html .= $this->renderTabs($enabledBlocks, $activeBlock, $savedData, $config);
|
||||
|
||||
// Actions: expand/collapse toggle (entire area is clickable)
|
||||
$html .= '<div class="entity-selector-actions btn-toggle-blocks" title="' . $this->trans('Show/hide details') . '">';
|
||||
$html .= '<i class="material-icons">' . ($collapsed ? 'expand_more' : 'expand_less') . '</i>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>'; // End tabs-row
|
||||
// Actions: expand/collapse toggle (entire area is clickable)
|
||||
$html .= '<div class="entity-selector-actions btn-toggle-blocks" title="' . $this->trans('Show/hide details') . '">';
|
||||
$html .= '<i class="material-icons">' . ($collapsed ? 'expand_more' : 'expand_less') . '</i>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>'; // End tabs-row
|
||||
|
||||
// Blocks content (hidden when collapsed)
|
||||
$blocksStyle = $collapsed ? ' style="display:none;"' : '';
|
||||
$html .= '<div class="entity-selector-blocks-content"' . $blocksStyle . '>';
|
||||
|
||||
// Blocks
|
||||
$html .= $this->renderBlocks($enabledBlocks, $activeBlock, $savedData, $config, $globalMode);
|
||||
|
||||
// Tips box
|
||||
$html .= $this->renderTipsBox();
|
||||
|
||||
$html .= '</div>'; // End blocks-content
|
||||
// Blocks content (hidden when collapsed)
|
||||
$blocksStyle = $collapsed ? ' style="display:none;"' : '';
|
||||
$html .= '<div class="entity-selector-blocks-content"' . $blocksStyle . '>';
|
||||
$html .= $this->renderBlocks($enabledBlocks, $activeBlock, $savedData, $config, $globalMode);
|
||||
$html .= $this->renderTipsBox();
|
||||
$html .= '</div>'; // End blocks-content
|
||||
}
|
||||
|
||||
// Hidden input (outside collapsed area)
|
||||
$html .= '<input type="hidden" name="' . $this->escapeAttr($config['name']) . '" value="' . $this->escapeAttr(json_encode($savedData)) . '">';
|
||||
|
||||
Reference in New Issue
Block a user