Skip to content

Commit 1ff72ec

Browse files
add rule to claude.md regarding forms in mat-dialog
1 parent 31d909f commit 1ff72ec

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

frontend/CLAUDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ Database configurations are defined in `src/app/consts/databases.ts`.
172172
- Example: `@if (condition) { ... }` instead of `<div *ngIf="condition">...</div>`
173173
- Example: `@for (item of items; track item.id) { ... }` instead of `<div *ngFor="let item of items">...</div>`
174174

175+
### Mat-Dialog Forms
176+
- **When a `mat-dialog` contains form elements and presumes form submission, `mat-dialog-content` and `mat-dialog-actions` MUST be wrapped in a `<form>` tag with an `(ngSubmit)` handler, and the primary action button inside `mat-dialog-actions` must use `type="submit"`.** This ensures the dialog properly supports keyboard submission (Enter key) and follows accessibility best practices.
177+
- Example:
178+
```html
179+
<form [formGroup]="myForm" (ngSubmit)="handleSubmit()">
180+
<mat-dialog-content>
181+
<!-- form fields -->
182+
</mat-dialog-content>
183+
<mat-dialog-actions>
184+
<button mat-button type="button" mat-dialog-close>Cancel</button>
185+
<button mat-flat-button type="submit" color="primary">Submit</button>
186+
</mat-dialog-actions>
187+
</form>
188+
```
189+
175190
### Naming Conventions
176191
- **Files**: `kebab-case.component.ts`
177192
- **Classes**: `PascalCase` (e.g., `DbTableSettingsComponent`)

0 commit comments

Comments
 (0)