Skip to content

Commit a9d4d74

Browse files
authored
[6.x] Hide set bodies when there are no fields (#14282)
Hide set bodies when there are no fields
1 parent d110982 commit a9d4d74

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

resources/js/components/fieldtypes/bard/Set.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
>
1919
<div ref="content" hidden />
2020
<header
21-
class="group/header animate-border-color show-focus-within flex items-center rounded-[calc(var(--radius-lg)-1px)] px-1.5 antialiased duration-200 bg-gray-100/50 dark:bg-gray-925 hover:bg-gray-100 dark:hover:bg-gray-950/45 border-gray-300 dark:shadow-md border-b-1 border-b-transparent"
21+
class="group/header animate-border-color show-focus-within flex items-center rounded-[calc(var(--radius-lg)-1px)] px-1.5 antialiased duration-200 bg-gray-100/50 dark:bg-gray-925 hover:bg-gray-100 dark:hover:bg-gray-950/45 border-gray-300 dark:shadow-md"
2222
:class="{
23-
'bg-gray-200/50 dark:bg-gray-950/35 rounded-b-none border-b-gray-300! dark:border-b-white/10!': !collapsed
23+
'bg-gray-200/50 dark:bg-gray-950/35 rounded-b-none': !collapsed && hasFields
2424
}"
2525
>
2626
<span v-if="!isReadOnly" data-drag-handle class="flex cursor-grab" @mousedown="enableDragging">
@@ -77,7 +77,12 @@
7777
</div>
7878
</header>
7979

80-
<div v-if="index !== undefined" v-show="!collapsed" :class="{ 'contain-paint': collapsed, 'isolate': !collapsed }">
80+
<div
81+
v-if="index !== undefined && hasFields"
82+
v-show="!collapsed"
83+
:class="{ 'contain-paint': collapsed, 'isolate': !collapsed }"
84+
class="border-t border-t-gray-300! dark:border-t-white/10!"
85+
>
8186
<FieldsProvider
8287
:fields="fields"
8388
:as-config="false"
@@ -143,6 +148,12 @@ export default {
143148
return this.config.fields;
144149
},
145150
151+
hasFields() {
152+
return Array.isArray(this.fields)
153+
? this.fields.length > 0
154+
: Object.keys(this.fields || {}).length > 0;
155+
},
156+
146157
display() {
147158
return __(this.config.display || this.values.type);
148159
},

resources/js/components/fieldtypes/replicator/Set.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const {
4848
const fieldPathPrefix = computed(() => `${props.fieldPath}.${props.index}`);
4949
const metaPathPrefix = computed(() => `${props.metaPath}.existing.${props.id}`);
5050
const isInvalid = computed(() => Object.keys(props.config).length === 0);
51+
const hasFields = computed(() => Array.isArray(props.config.fields) ? props.config.fields.length > 0 : Object.keys(props.config.fields || {}).length > 0);
5152
5253
const setGroup = computed(() => {
5354
if (replicatorSets.length < 1) return null;
@@ -140,9 +141,9 @@ reveal.use(rootEl, () => emit('expanded'));
140141
:data-type="config.handle"
141142
>
142143
<header
143-
class="group/header animate-border-color flex items-center show-focus-within rounded-[calc(var(--radius-lg)-1px)] px-1.5 antialiased duration-200 bg-gray-100/50 dark:bg-gray-925 hover:bg-gray-100 dark:hover:bg-gray-950/45 border-gray-300 dark:shadow-md border-b-1 border-b-transparent"
144+
class="group/header animate-border-color flex items-center show-focus-within rounded-[calc(var(--radius-lg)-1px)] px-1.5 antialiased duration-200 bg-gray-100/50 dark:bg-gray-925 hover:bg-gray-100 dark:hover:bg-gray-950/45 border-gray-300 dark:shadow-md"
144145
:class="{
145-
'bg-gray-200/50 dark:bg-gray-950/35 rounded-b-none border-b-gray-300! dark:border-b-white/10!': !collapsed
146+
'bg-gray-200/50 dark:bg-gray-950/35 rounded-b-none': !collapsed && hasFields
146147
}"
147148
>
148149
<Icon
@@ -201,7 +202,11 @@ reveal.use(rootEl, () => emit('expanded'));
201202
</div>
202203
</header>
203204
204-
<div v-show="!collapsed" :class="{ 'contain-paint': collapsed, 'isolate': !collapsed }">
205+
<div
206+
v-show="!collapsed && hasFields"
207+
:class="{ 'contain-paint': collapsed, 'isolate': !collapsed }"
208+
class="border-t border-t-gray-300! dark:border-t-white/10!"
209+
>
205210
<div :tabindex="collapsed ? -1 : undefined" :inert="collapsed">
206211
<FieldsProvider
207212
:fields="config.fields"

0 commit comments

Comments
 (0)