Skip to content

Commit a272c71

Browse files
authoredMar 25, 2024··
fix(pte): PTE inline block object modal closing on validation state changes (#6113)
1 parent ec3b25e commit a272c71

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed
 

‎dev/test-studio/schema/standard/portableText/allTheBellsAndWhistles.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,36 @@ export const ptAllTheBellsAndWhistlesType = defineType({
8888
type: 'string',
8989
name: 'color',
9090
title: 'Color',
91+
validation: (rule: Rule) => rule.required(),
9192
},
9293
],
9394
},
9495
],
9596
},
97+
of: [
98+
defineField({
99+
type: 'object',
100+
name: 'inlineImage',
101+
preview: {
102+
select: {
103+
media: 'asset',
104+
},
105+
},
106+
fields: [
107+
defineField({
108+
name: 'inlineImage',
109+
type: 'image',
110+
title: 'Inline image',
111+
}),
112+
defineField({
113+
name: 'caption',
114+
type: 'string',
115+
title: 'Caption',
116+
validation: (rule) => rule.required(),
117+
}),
118+
],
119+
}),
120+
],
96121
}),
97122

98123
defineField({
@@ -106,14 +131,14 @@ export const ptAllTheBellsAndWhistlesType = defineType({
106131
preview: {
107132
select: {
108133
media: 'asset',
109-
title: 'caption',
110134
},
111135
},
112136
fields: [
113137
defineField({
114138
title: 'Caption',
115139
name: 'caption',
116140
type: 'string',
141+
validation: (rule) => rule.required(),
117142
}),
118143
{
119144
name: 'alt',

‎packages/sanity/src/core/form/inputs/PortableText/object/InlineObject.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ export const InlineObject = (props: InlineObjectProps) => {
211211
<Tooltip
212212
placement="bottom"
213213
portal="editor"
214-
disabled={!tooltipEnabled}
214+
// If the object modal is open, disable the tooltip to avoid it rerendering the inner items when the validation changes.
215+
disabled={isOpen ? true : !tooltipEnabled}
215216
content={toolTipContent}
216217
>
217218
{/* This relative span must be here for the ToolTip to properly show */}
@@ -221,7 +222,14 @@ export const InlineObject = (props: InlineObjectProps) => {
221222
</Tooltip>
222223
</span>
223224
),
224-
[componentProps, memberItem?.elementRef, renderInlineBlock, toolTipContent, tooltipEnabled],
225+
[
226+
componentProps,
227+
memberItem?.elementRef,
228+
renderInlineBlock,
229+
toolTipContent,
230+
tooltipEnabled,
231+
isOpen,
232+
],
225233
)
226234
}
227235

0 commit comments

Comments
 (0)
Please sign in to comment.