Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content field is unusable in Admin UI. #100

Open
johnnycrich opened this issue Feb 19, 2021 · 2 comments
Open

Content field is unusable in Admin UI. #100

johnnycrich opened this issue Feb 19, 2021 · 2 comments

Comments

@johnnycrich
Copy link

Bug report

Describe the bug

The Content field renders no content blocks in the admin app editor.

To Reproduce

  1. Create a project via the keystone-app starter template, e.g. yarn create keystone-app content-field-test. I used the Todo starter.
  2. Add the @keystonejs/fields-content dependency (v9.0.6 as of now), e.g. yarn add @keystonejs/fields-content.
  3. In the newly created index.js, refactor as follows
const { Content, } = require('@keystonejs/fields-content');
....
	fields: {
		name: { type: Text, schemaDoc: 'This is the thing you need to do', isRequired: true },
		
		body: { type: Content,
		  blocks: [
		      Content.blocks.blockquote,
		      Content.blocks.heading
		  ],
	}
	....
  1. Run yarn dev.
  2. Navigate to http://localhost:3000/admin/todos and click Create.
  3. Focus the field for Body and click the plus icon. Note the "INSERT BLOCK" label followed by none of the content blocks (see screen below).

Expected behaviour

Clicking the plus icon in the Body field shows "INSERT BLOCK" label followed by the content blocks we specify for the field.

Screenshots

Screen Shot 2021-02-19 at 12 59 32 PM

System information

  • OS: macOS 10.15.7
  • Browser: FF or Chrome
  • node v14.4.0 (npm v7.5.3)

Additional context

Just poking around the Keystone 5 repository, I decided to run the Todo example directly, and replicated the issue there.

In the file ./packages/fields-content/src/views/editor/add-block.js, this assignment does not destructure as intended (unable to diagnose why) and is always undefined:
let { Sidebar } = blocks[key]

This is merely a very quick and dirty workaround.

function Sidebar(props) {
	let SidebarBlock = blocks[key];
	if(SidebarBlock.ToolbarElement) {
	  return (
	    <div>
	      <SidebarBlock.Node key={props.id} editor={props.editor} blocks={props.blocks} />           
	      <SidebarBlock.ToolbarElement key={`${props.id}-tool`} editor={props.editor} editorState={editorState} blocks={props.blocks} />
	    </div>
	  )
	}
	
	return <SidebarBlock.Node key={props.id} editor={props.editor} blocks={props.blocks} />
}
if (blocks[key] === undefined) {
	return null;
}

....

<Sidebar id={key} editor={editor} blocks={blocks} />
              

Doing this allows the content blocks/toolbar to show, though styling is rather broken and I am sure this would result in downstream issues.

@dejavu1987
Copy link

Having the same issue, actually, I tried all possible block types and only the image block is listed, including CloudinaryImage block.

@GLBaird
Copy link

GLBaird commented Feb 22, 2021

Also, the UI completely breaks if you add an image and set it to be aligned left or right. No error message appears if you upload an image which is too large. Will confuse users if this happens. Makes Keystone a bit unusable.

@timleslie timleslie transferred this issue from keystonejs/keystone Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants