Skip to content

Commit ca26402

Browse files
authored
fix(richtext-lexical): respect disableBlockName (#12597)
Fixes #12588 Previously, the new `disableBlockName` was not respected for lexical blocks. This PR adds a new e2e test and does some clean-up of previous e2e tests
1 parent 3022cab commit ca26402

File tree

11 files changed

+269
-314
lines changed

11 files changed

+269
-314
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"publish-prerelease": "pnpm --filter releaser publish-prerelease",
8585
"reinstall": "pnpm clean:all && pnpm install",
8686
"release": "pnpm --filter releaser release --tag latest",
87-
"runts": "cross-env NODE_OPTIONS=--no-deprecation node --no-deprecation --import @swc-node/register/esm-register",
87+
"runts": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" node --no-deprecation --no-experimental-strip-types --import @swc-node/register/esm-register",
8888
"script:build-template-with-local-pkgs": "pnpm --filter scripts build-template-with-local-pkgs",
8989
"script:gen-templates": "pnpm --filter scripts gen-templates",
9090
"script:gen-templates:build": "pnpm --filter scripts gen-templates --build",
@@ -93,17 +93,17 @@
9393
"script:pack": "pnpm --filter scripts pack-all-to-dest",
9494
"pretest": "pnpm build",
9595
"test": "pnpm test:int && pnpm test:components && pnpm test:e2e",
96-
"test:components": "cross-env NODE_OPTIONS=\" --no-deprecation\" jest --config=jest.components.config.js",
96+
"test:components": "cross-env NODE_OPTIONS=\" --no-deprecation --no-experimental-strip-types\" jest --config=jest.components.config.js",
9797
"test:e2e": "pnpm runts ./test/runE2E.ts",
98-
"test:e2e:debug": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 PWDEBUG=1 DISABLE_LOGGING=true playwright test",
99-
"test:e2e:headed": "cross-env NODE_OPTIONS=--no-deprecation NODE_NO_WARNINGS=1 DISABLE_LOGGING=true playwright test --headed",
98+
"test:e2e:debug": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PWDEBUG=1 DISABLE_LOGGING=true playwright test",
99+
"test:e2e:headed": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true playwright test --headed",
100100
"test:e2e:prod": "pnpm prepare-run-test-against-prod && pnpm runts ./test/runE2E.ts --prod",
101101
"test:e2e:prod:ci": "pnpm prepare-run-test-against-prod:ci && pnpm runts ./test/runE2E.ts --prod",
102-
"test:int": "cross-env NODE_OPTIONS=\"--no-deprecation\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
103-
"test:int:postgres": "cross-env NODE_OPTIONS=\"--no-deprecation\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
104-
"test:int:sqlite": "cross-env NODE_OPTIONS=\"--no-deprecation\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=sqlite DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
102+
"test:int": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
103+
"test:int:postgres": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=postgres DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
104+
"test:int:sqlite": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 PAYLOAD_DATABASE=sqlite DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=test/jest.config.js --runInBand",
105105
"test:types": "tstyche",
106-
"test:unit": "cross-env NODE_OPTIONS=\"--no-deprecation\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=jest.config.js --runInBand",
106+
"test:unit": "cross-env NODE_OPTIONS=\"--no-deprecation --no-experimental-strip-types\" NODE_NO_WARNINGS=1 DISABLE_LOGGING=true jest --forceExit --detectOpenHandles --config=jest.config.js --runInBand",
107107
"translateNewKeys": "pnpm --filter translations run translateNewKeys"
108108
},
109109
"lint-staged": {

packages/payload/src/utilities/getRequestLanguage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const getRequestLanguage = ({
1818
cookies,
1919
headers,
2020
}: GetRequestLanguageArgs): AcceptedLanguages => {
21-
const supportedLanguageKeys = <AcceptedLanguages[]>Object.keys(config.i18n.supportedLanguages)
21+
const supportedLanguageKeys = Object.keys(config.i18n.supportedLanguages) as AcceptedLanguages[]
2222
const langCookie = cookies.get(`${config.cookiePrefix || 'payload'}-lng`)
2323

2424
const languageFromCookie: AcceptedLanguages = (

packages/richtext-lexical/src/features/blocks/client/component/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
441441
>
442442
{blockDisplayName ?? formData?.blockType}
443443
</Pill>
444-
{!disableBlockName && (
444+
{!disableBlockName && !clientBlock?.admin?.disableBlockName && (
445445
<SectionTitle
446446
path="blockName"
447447
readOnly={parentLexicalRichTextField?.admin?.readOnly || false}
@@ -479,6 +479,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
479479
EditButton,
480480
RemoveButton,
481481
blockDisplayName,
482+
clientBlock?.admin?.disableBlockName,
482483
editor,
483484
formData.blockType,
484485
i18n,
@@ -488,8 +489,6 @@ export const BlockComponent: React.FC<Props> = (props) => {
488489
],
489490
)
490491

491-
const clientBlockFields = clientBlock?.fields ?? []
492-
493492
const BlockDrawer = useMemo(
494493
() => () => (
495494
<EditDepthProvider>
@@ -503,7 +502,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
503502
{initialState ? (
504503
<>
505504
<RenderFields
506-
fields={clientBlockFields}
505+
fields={clientBlock?.fields ?? []}
507506
forceRender
508507
parentIndexPath=""
509508
parentPath="" // See Blocks feature path for details as for why this is empty
@@ -543,7 +542,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
543542
},
544543
]}
545544
el="div"
546-
fields={clientBlockFields}
545+
fields={clientBlock?.fields ?? []}
547546
initialState={initialState}
548547
onChange={[onChange]}
549548
onSubmit={(formState, newData) => {
@@ -567,7 +566,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
567566
CustomBlock={CustomBlock}
568567
EditButton={EditButton}
569568
errorCount={errorCount}
570-
formSchema={clientBlockFields}
569+
formSchema={clientBlock?.fields ?? []}
571570
initialState={initialState}
572571
nodeKey={nodeKey}
573572
RemoveButton={RemoveButton}
@@ -578,7 +577,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
578577
BlockCollapsible,
579578
BlockDrawer,
580579
CustomBlock,
581-
clientBlockFields,
580+
clientBlock?.fields,
582581
RemoveButton,
583582
EditButton,
584583
editor,

test/lexical/collections/Lexical/blocks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,16 @@ export const CodeBlock: Block = {
444444
],
445445
slug: 'code',
446446
}
447+
448+
export const NoBlockNameBlock: Block = {
449+
fields: [
450+
{
451+
name: 'text',
452+
type: 'text',
453+
},
454+
],
455+
admin: {
456+
disableBlockName: true,
457+
},
458+
slug: 'noBlockName',
459+
}

0 commit comments

Comments
 (0)