aglinxinyuan opened a new issue, #7431:
URL: https://github.com/apache/texera/issues/7431
### Describe the bug
In `repeat-dnd.component.html` the per-row remove button is meant to be
disabled when the field is read-only, but the guard never takes effect: the
`*ngFor` shadows the name it reads.
```html
<div *ngFor="let field of field.fieldGroup; let i = index" cdkDrag
class="dnd-row">
...
<button
(click)="remove(i)"
class="dnd-remove-button"
[disabled]="field.templateOptions?.disabled"> <!-- `field` here is the
ROW, not the section -->
```
Inside the loop, `field` is the loop variable — one entry of
`field.fieldGroup` — not the component's own `field`. Sub-fields carry no
`templateOptions.disabled`, so the expression is always `undefined` and the
button is never disabled.
The add button, which sits **outside** the loop, reads the same expression
correctly and does disable.
### To Reproduce
Render `FormlyRepeatDndComponent` with `field.templateOptions.disabled =
true` and inspect the two buttons:
| Button | In the `*ngFor`? | Rendered |
|---|---|---|
| add | no | `disabled="true"` |
| remove (each row) | yes | no `disabled` attribute |
Confirmed in a spec run against `main`: the add button renders
`disabled="true"` while the remove buttons render no disabled attribute at all
with the identical binding.
### Expected behavior
A read-only repeat section should not offer per-row removal. Both buttons
should be disabled together.
### Suggested fix
Rename the loop variable so it stops shadowing, e.g.:
```html
<div *ngFor="let row of field.fieldGroup; let i = index" cdkDrag
class="dnd-row">
```
and leave the `[disabled]="field.templateOptions?.disabled"` bindings
pointing at the section's field. The inner `formly-field` binding would become
`[field]="subField"` off `row.fieldGroup` accordingly.
### Additional context
Found while adding rendering tests for this component (the spec previously
exercised only `onDrop` and never rendered). Those tests deliberately assert
the add button's gating and **not** the remove buttons', so that the current
behaviour is not cemented before this is fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]