Preview not working properly after upgrade to 2.1.5
See original GitHub issueDescribe the bug
Previews using a react component returns undefined
after upgrading from the following packages:
@sanity/base 2.1.2 → 2.1.5
@sanity/components 2.1.0 → 2.1.4
@sanity/core 2.1.2 → 2.1.4
@sanity/default-layout 2.1.3 → 2.1.5
@sanity/default-login 2.1.0 → 2.1.4
@sanity/desk-tool 2.1.3 → 2.1.5
@sanity/google-maps-input 2.1.3 → 2.1.5
@sanity/vision 2.1.0 → 2.1.4
To Reproduce
Steps to reproduce the behavior:
- Create a fresh project using the cli.
- Add the following to your
schemas/schema.js
.
// First, we must import the schema creator
import createSchema from "part:@sanity/base/schema-creator";
// Then import schema types from any plugins that might expose them
import schemaTypes from "all:part:@sanity/base/schema-type";
const supportedLanguages = [
{ id: "en", title: "English", isDefault: true },
{ id: "da", title: "Danish" },
{ id: "nb", title: "Norwegian" },
{ id: "sv", title: "Swedish" },
];
// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
// We name our schema
name: "default",
// Then proceed to concatenate our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
{
name: "localeString",
type: "object",
fieldsets: [
{
title: "Translations",
name: "translations",
options: { collapsible: true },
},
],
fields: [
{
name: "key",
title: "Key",
type: "string",
validation: (Rule) =>
Rule.lowercase().warning("All lower case for a key is prefered"),
},
...supportedLanguages.map((lang) => ({
title: lang.title,
name: lang.id,
type: "string",
fieldset: lang.isDefault ? null : "translations",
})),
],
preview: {
select: {
title: "key",
...supportedLanguages.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur.id }),
{}
),
},
prepare: ({ title, ...lngs }) => {
const missingLngs = Object.entries(lngs)
.filter((lng) => !lng[1])
.map((lng) => lng[0]);
return {
title: `${title} - ${lngs.en}`,
subtitle:
missingLngs.length > 0
? `Missing: ${missingLngs.join(", ")}`
: "Everything present",
media: <span>{missingLngs.length > 0 ? "🚨" : "✔️"}</span>,
};
},
},
},
{
title: "Translations",
name: "namespaces",
type: "document",
fields: [
{
name: "namespace",
title: "Namespace",
type: "string",
validation: (Rule) => Rule.required().lowercase(),
},
{
title: "translations",
name: "translations",
type: "array",
of: [{ type: "localeString" }],
validation: (Rule) =>
Rule.unique().error(
"Should not have a duplicate translation in the same namespace"
),
},
],
},
]),
});
- Start studio and create a translation document. Add a value to the namespace field and add a new translation to the translation array.
- See that array field is returned as
undefined
instead of specified component.
Expected behavior
Expected too see an array element with ✔️ or 🚨 along with a title and subtitle, as seen in the screenshot. Instead I get undefined
and no icon. This worked on previous versions mentioned above.
Screenshots
Expected behaviour
Error behaviour
Which versions of Sanity are you using?
Run sanity versions
in the terminal and copy-paste the result here.
@sanity/cli 1.149.16 (latest: 2.1.4)
@sanity/base 2.1.5 (up to date)
@sanity/components 2.1.4 (up to date)
@sanity/core 2.1.4 (up to date)
@sanity/default-layout 2.1.5 (up to date)
@sanity/default-login 2.1.4 (up to date)
@sanity/desk-tool 2.1.5 (up to date)
@sanity/vision 2.1.4 (up to date)
What operating system are you using?
wsl2 ubuntu
Which versions of Node.js / npm are you running?
6.14.5
v14.4.0
Additional context
Security issue? No
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
What's new in the updates for macOS Big Sur? - Apple Support
macOS Big Sur 11.6.7 fixes an issue where Mail and other apps, such as Microsoft Outlook, can't open attachments if the app required...
Read more >[Update] T4 Framework 2.1.5: improvements and multiple bug ...
Hi guys,. T4 Framework 2.1.5 is here. This new version is updated for improvements and multiple bug fixes:.
Read more >What is the migration guidelines to migrate .NET Core 2.1 ...
Hello! I'm looking for some guidance on migrating .NET Core 2.1 applications to .NET 6(Preview). As .NET 6 is going to be a...
Read more >Mac Release Notes - Your Journal for Life | Day One
A few bug fixes that needed to be addressed earlier than our usual release schedule. 6.9.2 (September 21, 2021). Fixed an issue with...
Read more >Help Center BIAS FX 2 Desktop Update History / Release Notes
BIAS FX 2 Desktop Update History / Release Notes · Minor bugs fixes and performance improvements. · Fixed "No guitar match profile available...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @bjoerge - Look fine here as well 👍
thanks @bjoerge - works fine now.