feat(Table): support validate InCell Mode#7437
Merged
Conversation
Introduces an IsFormless parameter to ValidateForm, allowing it to operate without rendering a form element, which is used for in-cell editing in Table. Updates Table to use this mode for in-cell editing, ensures validation is performed, and manages EditContext accordingly. Also fixes validation logic and EditTemplate usage to support the new mode.
|
Thanks for your PR, @celadaris. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
Reviewer's GuideAdds a formless mode to ValidateForm so it can participate in validation without rendering a , and wires Table’s in‑cell editing to use this mode with proper EditContext reuse and validation behavior.Sequence diagram for Table in‑cell update using formless ValidateFormsequenceDiagram
actor User
participant Table as Table_TItem_
participant ValidateForm
participant EditContext
User->>Table: ClickUpdateButtonCallback()
activate Table
Table->>ValidateForm: Validate()
alt validation fails
ValidateForm-->>Table: false
Table-->>User: return without saving
else validation succeeds
ValidateForm-->>Table: true
Table->>ValidateForm: GetEditContext()
alt formless context exists
ValidateForm-->>Table: EditContext
else no formless context
Table->>EditContext: new EditContext(EditModel)
Note right of EditContext: Created locally in Table
end
Table->>Table: SaveAsync(context, changedType)
Table-->>User: update completed
end
deactivate Table
Class diagram for ValidateForm formless mode and Table in‑cell integrationclassDiagram
class ValidateForm {
+bool? ShowLabelTooltip
+bool IsFormless
-BootstrapBlazorDataAnnotationsValidator Validator
-EditContext _formlessEditContext
+void OnParametersSet()
+bool Validate()
+EditContext GetEditContext()
-Task OnValidSubmitForm(EditContext context)
-Task OnInvalidSubmitForm(EditContext context)
-Task ValidateObject(ValidationContext context, List~ValidationResult~ results)
-Dictionary _validatorCache
-bool _invalid
}
class EditContext {
}
class Table~TItem~ {
-bool AddInCell
-bool EditInCell
-TItem EditModel
-IEnumerable~TItem~ SelectedRows
-bool ShowExtendButtons
-bool IsExtendButtonsInRowHeader
-bool InCellMode
-ValidateForm _inCellValidateForm
+void ClickEditButton(TItem item)
+Task ClickUpdateButtonCallback()
-Task SaveAsync(EditContext context, ItemChangedType changedType)
-RenderFragment RenderContentRow(TItem item)
-RenderFragment RenderRowExtendButtons(TItem item)
-IEnumerable GetVisibleColumns()
}
class BootstrapBlazorDataAnnotationsValidator {
}
class ItemChangedType {
}
ValidateForm --> EditContext : uses
ValidateForm --> BootstrapBlazorDataAnnotationsValidator : contains
Table~TItem~ --> ValidateForm : uses _inCellValidateForm
Table~TItem~ --> EditContext : passes to SaveAsync
Table~TItem~ --> ItemChangedType : parameter
Flow diagram for Table row rendering with in‑cell formless validationflowchart TD
A[Start row render for item] --> B{"InCellMode && SelectedRows.FirstOrDefault() == item"}
B -- Yes (in-cell edit row) --> C[Render ValidateForm IsFormless true with Model EditModel]
C --> D{RowContentTemplate set?}
D -- Yes --> E[Invoke RowContentTemplate with item, columns, ActiveRenderMode]
D -- No --> F[RenderContentRow item]
E --> G{ShowExtendButtons && !IsExtendButtonsInRowHeader}
F --> G
G -- Yes --> H[RenderRowExtendButtons item]
G -- No --> I[Skip extend buttons]
H --> J[End in-cell row]
I --> J
B -- No (normal row) --> K{RowContentTemplate set?}
K -- Yes --> L[Invoke RowContentTemplate with item, columns, ActiveRenderMode]
K -- No --> M[RenderContentRow item]
L --> N{ShowExtendButtons && !IsExtendButtonsInRowHeader}
M --> N
N -- Yes --> O[RenderRowExtendButtons item]
N -- No --> P[Skip extend buttons]
O --> Q[End normal row]
P --> Q
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The in-cell row rendering block in Table.razor now duplicates the RowContentTemplate/RenderContentRow + extend-buttons logic in both the formless and non-formless branches; consider extracting this into a small helper/render fragment to avoid duplication and keep future changes in one place.
- ValidateForm.GetEditContext() currently returns the private _formlessEditContext but is callable regardless of IsFormless; consider either guarding it so it only returns a non-null context when IsFormless is true or wiring it to the normal EditForm EditContext as well, to avoid confusing nulls or divergent behavior for callers.
- In the formless ValidateForm markup, _formlessEditContext is cascaded with IsFixed="false" but its lifetime is managed in OnParametersSet; double-check whether it would be cleaner to create/update the EditContext in OnInitialized/OnParametersSet and always cascade a non-null instance to avoid transient null cascades for consumers that rely on EditContext being present.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The in-cell row rendering block in Table.razor now duplicates the RowContentTemplate/RenderContentRow + extend-buttons logic in both the formless and non-formless branches; consider extracting this into a small helper/render fragment to avoid duplication and keep future changes in one place.
- ValidateForm.GetEditContext() currently returns the private _formlessEditContext but is callable regardless of IsFormless; consider either guarding it so it only returns a non-null context when IsFormless is true or wiring it to the normal EditForm EditContext as well, to avoid confusing nulls or divergent behavior for callers.
- In the formless ValidateForm markup, _formlessEditContext is cascaded with IsFixed="false" but its lifetime is managed in OnParametersSet; double-check whether it would be cleaner to create/update the EditContext in OnInitialized/OnParametersSet and always cascade a non-null instance to avoid transient null cascades for consumers that rely on EditContext being present.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7437 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 749 749
Lines 32845 32894 +49
Branches 4563 4570 +7
=========================================
+ Hits 32845 32894 +49
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ArgoZhang
approved these changes
Dec 28, 2025
ArgoZhang
added a commit
that referenced
this pull request
Dec 28, 2025
* refactor: 代码重构精简代码逻辑 * refactor: 精简代码 * refactor: 优化性能 * refactor: 消除提示信息 * test: 增加单元测试 * refactor: 更新单元测试 --------- Co-authored-by: Argo Zhang <argo@live.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces an IsFormless parameter to ValidateForm, allowing it to operate without rendering a form element, which is used for in-cell editing in Table. Updates Table to use this mode for in-cell editing, ensures validation is performed, and manages EditContext accordingly. Also fixes validation logic and EditTemplate usage to support the new mode.
Link issues
fixes #7139
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a formless validation mode to ValidateForm and integrate it with Table in-cell editing to enable proper validation without rendering a form element.
New Features:
Bug Fixes:
Enhancements: