The content form shows a Layout tab with the raw blocks and blocks_layout fields

Open Beginner friendly
#558 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
frontend

Research direction

Start with packages/cmsui/components/ContentForm/ContentForm.tsx and the schema handling in routes/add.tsx, routes/edit.tsx, and routes/translate.tsx; compare the existing Volto helper mentioned in the issue. Add a unit test for a layout fieldset that becomes empty and one that retains other fields. Done means the content form hides blocks and blocks_layout and omits an empty Layout tab across all three views.

Written by the indexing model from the issue text.

Description

01 type: bug

Problem

The content form in the CMS UI (the Content tab of the add, edit and translate views) shows a Layout tab. It holds the blocks and blocks_layout fields, which are raw JSON fields that editors must not edit by hand. Aurora edits the page body in the Blocks tab, so this tab shouldn't be there.

The tab comes from the content type schema. GET @types/Document returns:

{ "id": "layout", "title": "Layout", "fields": ["blocks", "blocks_layout"] }

with blocks and blocks_layout as json widgets. ContentForm (packages/cmsui/components/ContentForm/ContentForm.tsx) gets the schema from @types unchanged in routes/add.tsx, routes/edit.tsx and routes/translate.tsx, and SchemaFieldsets renders every fieldset that has fields, so the Layout tab appears.

Steps to reproduce

  1. Log in and edit a page.
  2. Open the Content tab.
  3. A Layout tab is listed next to the other fieldsets, with the Blocks and Blocks Layout fields.

How Volto handles it

Volto's Form removes these fields before rendering, in removeBlocksLayoutFields (packages/volto/src/components/manage/Form/Form.jsx): it filters blocks and blocks_layout out of the layout fieldset and drops the fieldset when it ends up empty.

Aurora has no equivalent. The only place that skips these fields today is the source panel of routes/translate.tsx, which leaves out blocks, blocks_layout and changeNote when it lists the source values, but its form still shows the tab.

Expected

The content form doesn't show blocks or blocks_layout, and doesn't show the Layout tab when those were its only fields. If a behavior adds other fields to the layout fieldset, the tab stays with those fields.

Possible direction

Port removeBlocksLayoutFields as a schema helper (in @plone/helpers or @plone/cmsui) and apply it once where the form gets its schema, so the add, edit and translate views all use it, with a unit test for both cases (a fieldset that becomes empty, and one that keeps other fields).

Dominant language
JavaScript
Stars
13
Forks
10
Avg merge
2d 14h
Merged PRs (30d)
82

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/aurora

All issues in plone/aurora

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.