Angular Material: TableRenderer ignores hidden, so rules do not hide an array control

Aperta Adatta ai principianti
#2,662 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
angular, typescript
Ambito
frontend

Direzione di ricerca

Leggi packages/angular-material/src/library/other/table.renderer.ts e confronta il relativo template con i template di testo, numero, enum o VerticalLayoutRenderer che associano hidden. Riproduci il problema con lo schema e lo schema UI forniti, iniziando con show: false. Il lavoro è completato quando la tabella è nascosta mentre la regola SHOW è false e diventa visibile quando la condizione è true.

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

Descrizione

angular material
Describe the bug

In the Angular Material renderers, TableRenderer ignores hidden. A SHOW or HIDE rule on a control that the table renderer draws, such as an array of primitives, has no effect: the table stays visible.

TableRenderer extends JsonFormsArrayControl, which sets hidden from the rule's visible state like the other controls. But the template in packages/angular-material/src/library/other/table.renderer.ts never reads it. Other renderers bind it, for example [ngStyle]="{ display: hidden ? 'none' : '' }" in the text, number and enum controls and in VerticalLayoutRenderer.

Expected behavior

The table is hidden while its rule says so, as the other controls are.

Steps to reproduce the issue
  1. Render with angularMaterialRenderers, using this schema and UI schema:

    {
      "type": "object",
      "properties": {
        "show": { "type": "boolean" },
        "names": { "type": "array", "items": { "type": "string" } }
      }
    }
    
    {
      "type": "VerticalLayout",
      "elements": [
        { "type": "Control", "scope": "#/properties/show" },
        {
          "type": "Control",
          "scope": "#/properties/names",
          "rule": {
            "effect": "SHOW",
            "condition": { "scope": "#/properties/show", "schema": { "const": true } }
          }
        }
      ]
    }
    
  2. Start with the data { "show": false }.

  3. The names table is still shown. A string control with the same rule is hidden.

Which Version of JSON Forms are you using?

v3.8.0 (and master)

Package

Angular Material Renderers

Additional context

Workaround: put the rule on a one-element VerticalLayout around the control. Layouts honour it.

A likely fix: wrap the template's root in @if (!hidden), or bind [ngStyle]="{ display: hidden ? 'none' : '' }" on .table-container, as the other renderers do.

Found while building the web UI of an open-source firewall project; this report was drafted with Claude Code.

Lingua principale
TypeScript
Stelle
2.8k
Fork
423
Merge medio
5g 16h
PR unite (30g)
9

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 eclipsesource/jsonforms

Tutte le issue di eclipsesource/jsonforms

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.