Skip to content

Commit 19abc17

Browse files
authored
πŸ› Fix redirect URIs field not displaying as a list of strings (#303)
## Description ✏️ Relates to SSWConsulting/SSW.Rules#2171 Fixed the issue where the redirect URIs field was not displaying as a list of strings by adding support for primitive list fields in ConditionalHiddenField ## Screenshot (optional) ✏️ <img width="2792" height="1423" alt="image" src="https://github.com/user-attachments/assets/d7b8ebab-3bf3-4bcb-a967-61bf52a643b9" /> <!-- Check out the relevant rules - https://www.ssw.com.au/rules/use-pull-request-templates-to-communicate-expectations/ - https://www.ssw.com.au/rules/rules-to-better-pull-requests - https://www.ssw.com.au/rules/write-a-good-pull-request - https://www.ssw.com.au/rules/over-the-shoulder-prs - https://www.ssw.com.au/rules/do-you-use-co-creation-patterns -->
1 parent af8201e commit 19abc17

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

β€Žtina/collection/rule.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const Rule: Collection = {
126126
type: "object",
127127
label: "Related Rules",
128128
name: "related",
129-
description: "The URIs of rules that should be suggested based on the content of this rule.",
129+
description: "URIs of related rules to suggest.",
130130
list: true,
131131
searchable: false,
132132
ui: {

β€Žtina/fields/ConditionalHiddenField.tsxβ€Ž

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import React, { useEffect, useRef, useState } from "react";
4-
import { GroupListFieldPlugin, ImageField, MdxFieldPluginExtendible, ToggleFieldPlugin, wrapFieldsWithMeta } from "tinacms";
4+
import { GroupListFieldPlugin, ImageField, MdxFieldPluginExtendible, ToggleFieldPlugin, wrapFieldsWithMeta, ListFieldPlugin } from "tinacms";
55

66
/**
77
* Conditionally hides string, rich-text, boolean, image, and list fields (and their labels) on create mode,
@@ -224,6 +224,8 @@ export const ConditionalHiddenField = wrapFieldsWithMeta((props: any) => {
224224

225225
const isListField = field.list === true;
226226
const isAlwaysVisible = isAlwaysVisibleField();
227+
const isObjectListField = isListField && field.type === "object";
228+
const isPrimitiveListField = isListField && field.type !== "object";
227229

228230
// ============================================================================
229231
// CUSTOM CONDITION LOGIC
@@ -359,11 +361,23 @@ export const ConditionalHiddenField = wrapFieldsWithMeta((props: any) => {
359361
default:
360362
// Handle list fields
361363
if (isListField) {
362-
return (
363-
<div ref={containerRef}>
364-
<GroupListFieldPlugin.Component {...propsWithoutError} />
365-
</div>
366-
);
364+
// Object lists β†’ GroupList
365+
if (isObjectListField) {
366+
return (
367+
<div ref={containerRef}>
368+
<GroupListFieldPlugin.Component {...propsWithoutError} />
369+
</div>
370+
);
371+
}
372+
373+
// Primitive lists (string/number) β†’ ListField
374+
if (isPrimitiveListField) {
375+
return (
376+
<div ref={containerRef}>
377+
<ListFieldPlugin.Component {...propsWithoutError} />
378+
</div>
379+
);
380+
}
367381
}
368382

369383
// Default: string input or textarea

β€Žtina/tina-lock.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
Β (0)