Skip to content

Commit bcf1eed

Browse files
authored
feat: Do not filter out empty props (#4760)
## Description This #4759 allows to not filter out empty props ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 1f48985 commit bcf1eed

File tree

8 files changed

+16
-37
lines changed

8 files changed

+16
-37
lines changed

fixtures/webstudio-remix-vercel/.webstudio/data.json

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"build": {
3-
"id": "0d43a990-f5cd-43c3-ab26-863ebe71eb27",
3+
"id": "1bd755a0-9c8a-416b-b373-2123f3568393",
44
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
5-
"version": 463,
6-
"createdAt": "2025-01-18T19:56:10.675+00:00",
7-
"updatedAt": "2025-01-18T19:56:10.675+00:00",
5+
"version": 464,
6+
"createdAt": "2025-01-19T14:02:13.405+00:00",
7+
"updatedAt": "2025-01-19T14:02:13.405+00:00",
88
"pages": {
99
"meta": {
1010
"siteName": "KittyGuardedZone",
@@ -2950,16 +2950,6 @@
29502950
"value": "7Db64ZXgYiRqKSQNR-qTQ"
29512951
}
29522952
],
2953-
[
2954-
"oCeOjUq5kg_g-0dq5iApN",
2955-
{
2956-
"id": "oCeOjUq5kg_g-0dq5iApN",
2957-
"instanceId": "EveN4Skg9xb8Lj1QJcW52",
2958-
"name": "name",
2959-
"type": "string",
2960-
"value": ""
2961-
}
2962-
],
29632953
[
29642954
"9axbHjZtX8BX6vXEai1xq",
29652955
{

fixtures/webstudio-remix-vercel/app/__generated__/$resources.sitemap.xml.ts

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-remix-vercel/app/__generated__/[head-tag]._index.tsx

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-remix-vercel/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"typecheck": "tsc",
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
9-
"fixtures:sync": "pnpm cli sync --buildId 0d43a990-f5cd-43c3-ab26-863ebe71eb27 && pnpm prettier --write ./.webstudio/",
9+
"fixtures:sync": "pnpm cli sync --buildId 1bd755a0-9c8a-416b-b373-2123f3568393 && pnpm prettier --write ./.webstudio/",
1010
"fixtures:build": "pnpm cli build --template vercel --template internal --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"private": true,

packages/sdk-components-react/src/head-link.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ export const HeadLink = forwardRef<
6262
const cleanOrderedProps: Record<string, unknown> = {};
6363

6464
for (const prop of propsSet) {
65-
// Boolean check is not a mistake; it excludes empty values.
66-
// Empty properties must be excluded because there is no UI to reset them to undefined.
67-
if (prop in props && Boolean(props[prop])) {
65+
if (prop in props && props[prop] !== undefined) {
6866
cleanOrderedProps[prop] = props[prop];
6967
}
7068
}

packages/sdk-components-react/src/head-meta.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ export const HeadMeta = forwardRef<
2424
const cleanOrderedProps: Record<string, unknown> = {};
2525

2626
for (const prop of propsSet) {
27-
// Boolean check is not a mistake; it excludes empty values.
28-
// Empty properties must be excluded because there is no UI to reset them to undefined.
29-
// Additionally, <meta property="" name="someName" content="someContent" /> is invalid.
30-
if (prop in props && Boolean(props[prop])) {
27+
if (prop in props && props[prop] !== undefined) {
3128
cleanOrderedProps[prop] = props[prop];
3229
}
3330
}

packages/sdk-components-react/src/head-title.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export const HeadTitle = forwardRef<
2424
const cleanOrderedProps: Record<string, unknown> = {};
2525

2626
for (const prop of propsSet) {
27-
// Boolean check is not a mistake; it excludes empty values.
28-
// Empty properties must be excluded because there is no UI to reset them to undefined.
29-
if (prop in props && Boolean(props[prop])) {
27+
if (prop in props && props[prop] !== undefined) {
3028
cleanOrderedProps[prop] = props[prop];
3129
}
3230
}

packages/sdk-components-react/src/xml-node.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const XmlNode = forwardRef<ElementRef<"div">, Props>(
3333
([key]) =>
3434
key.startsWith("data-") === false && key.startsWith("aria-") === false
3535
)
36-
.filter(([key]) => key !== "tabIndex")
36+
.filter(([key]) => key.toLowerCase() !== "tabindex")
3737
.filter(([, value]) => typeof value !== "function");
3838

3939
const elementName = tag

0 commit comments

Comments
 (0)