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

Aperta Adatta ai principianti
#558 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia da packages/cmsui/components/ContentForm/ContentForm.tsx e dalla gestione dello schema in routes/add.tsx, routes/edit.tsx e routes/translate.tsx; confronta l’helper Volto esistente menzionato nell’issue. Aggiungi un test unitario per un fieldset Layout che diventa vuoto e uno per un fieldset che conserva altri campi. Il lavoro è completato quando il modulo dei contenuti nasconde blocks e blocks_layout e omette una scheda Layout vuota in tutte e tre le viste.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
JavaScript
Stelle
13
Fork
10
Merge medio
2g 14h
PR unite (30g)
82

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di plone/aurora

Tutte le issue di plone/aurora

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.