File tree Expand file tree Collapse file tree 5 files changed +40
-2
lines changed
richtext-lexical/src/field
test/lexical/collections/Lexical Expand file tree Collapse file tree 5 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,6 @@ const RichTextComponent: React.FC<
184184 />
185185 { AfterInput }
186186 </ ErrorBoundary >
187- { Description }
188187 < RenderCustomComponent
189188 CustomComponent = { Description }
190189 Fallback = { < FieldDescription description = { description } path = { path } /> }
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export const Form: React.FC<FormProps> = (props) => {
104104 const { startRouteTransition } = useRouteTransition ( )
105105 const { getUploadHandler } = useUploadHandlers ( )
106106
107- const { config, getEntityConfig } = useConfig ( )
107+ const { config } = useConfig ( )
108108
109109 const [ disabled , setDisabled ] = useState ( disabledFromProps || false )
110110 const [ isMounted , setIsMounted ] = useState ( false )
Original file line number Diff line number Diff line change 1+ export const Description = ( ) => {
2+ return (
3+ < div className = "lexical-blocks-custom-description" style = { { color : 'red' } } >
4+ My Custom Lexical Description
5+ </ div >
6+ )
7+ }
Original file line number Diff line number Diff line change @@ -1446,6 +1446,29 @@ describe('lexicalMain', () => {
14461446 page . getByText ( 'Creating new User' )
14471447 } )
14481448
1449+ test ( 'ensure custom Description component is rendered only once' , async ( ) => {
1450+ await navigateToLexicalFields ( )
1451+ const lexicalWithBlocks = page . locator ( '.rich-text-lexical' ) . nth ( 2 )
1452+ await lexicalWithBlocks . scrollIntoViewIfNeeded ( )
1453+ await expect ( lexicalWithBlocks ) . toBeVisible ( )
1454+
1455+ await expect ( lexicalWithBlocks . locator ( '.lexical-blocks-custom-description' ) ) . toHaveCount ( 1 )
1456+ await expect ( lexicalWithBlocks . locator ( '.lexical-blocks-custom-description' ) ) . toBeVisible ( )
1457+
1458+ await expect ( lexicalWithBlocks . locator ( '.field-description' ) ) . toHaveCount ( 0 )
1459+ } )
1460+
1461+ test ( 'ensure admin.description property is rendered' , async ( ) => {
1462+ await navigateToLexicalFields ( )
1463+ const lexicalSimple = page . locator ( '.rich-text-lexical' ) . nth ( 1 )
1464+ await lexicalSimple . scrollIntoViewIfNeeded ( )
1465+ await expect ( lexicalSimple ) . toBeVisible ( )
1466+
1467+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toHaveCount ( 1 )
1468+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toBeVisible ( )
1469+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toHaveText ( 'A simple lexical field' )
1470+ } )
1471+
14491472 test ( 'ensure links can created from clipboard and deleted' , async ( ) => {
14501473 await navigateToLexicalFields ( )
14511474 const richTextField = page . locator ( '.rich-text-lexical' ) . first ( )
Original file line number Diff line number Diff line change @@ -309,6 +309,9 @@ export const getLexicalFieldsCollection: (args: {
309309 {
310310 name : 'lexicalSimple' ,
311311 type : 'richText' ,
312+ admin : {
313+ description : 'A simple lexical field' ,
314+ } ,
312315 editor : lexicalEditor ( {
313316 features : ( { defaultFeatures } ) => [
314317 //TestRecorderFeature(),
@@ -347,6 +350,12 @@ export const getLexicalFieldsCollection: (args: {
347350 {
348351 name : 'lexicalWithBlocks' ,
349352 type : 'richText' ,
353+ admin : {
354+ components : {
355+ Description : '/collections/Lexical/components/Description.js#Description' ,
356+ } ,
357+ description : 'Should not be rendered' ,
358+ } ,
350359 editor : lexicalEditor ( {
351360 admin : {
352361 hideGutter : false ,
You can’t perform that action at this time.
0 commit comments