* Describe the bug
Hi, folks!
When I click on Edit button on the filled out form, the Edit Window shows me a blank form without any data filled in it. Sometimes, after reloading the page the data will be shown.
* Environment
Database type and version: PostgreSQL 16
Deployment Methods: Docker Compose
Docker image version: nocobase/nocobase:latest
* How To Reproduce
Click on Edit button on the form.
Expected behavior
The Edit Window will show Editor with all my data previously filled in the form.
Screenshots
Logs
Please upgrade to the latest version and check whether the issue is resolved.
nocobase:main
← nocobase:task-5800
opened 04:49AM - 04 Jun 25 UTC
### This is a ...
- [ ] New feature
- [ ] Improvement
- [x] Bug fix
- [ ] Ot… hers
### Motivation
Fields were not displaying properly in block templates due to multiple API requests returning inconsistent data, which caused linkage rules to produce different results and ultimately led to field visibility issues. Investigation revealed that block templates were triggering duplicate API requests - an initial request and additional requests after template completion - resulting in data inconsistencies that affected form field display logic.
### Description
<!--
Please describe the key changes made in this PR clearly and concisely,
mention any potential risks,
and provide some testing suggestions.
-->
This PR fixes a critical bug where fields were not displaying correctly in block templates due to duplicate API requests causing data inconsistencies and affecting linkage rule evaluation.
**Root Cause:**
Block templates were making multiple API requests that returned inconsistent data. This inconsistency caused linkage rules to evaluate differently across requests, leading to field visibility issues where some fields would not display properly.
**Key Changes:**
1. **Enhanced TemplateBlockProvider**: Added `isBlockTemplate` function to detect whether a block is a template block by recursively checking schema properties for `BlockTemplate` components.
2. **Fixed DataBlockRequestProvider**: Implemented request deduplication logic that prevents API calls for template blocks until the template has finished loading (`templateFinished` is true), ensuring consistent data and preventing linkage rule conflicts.
3. **Improved Details Component**: Updated empty state handling for template blocks to properly consider both loading state and template completion status, preventing premature empty state display.
4. **Enhanced Form Component**: Added proper data checking in form effects to prevent linkage rules from running on incomplete or inconsistent data.
5. **Code Cleanup**: Removed unused imports and deprecated code (Spin component, useCollectionManager_deprecated) that were no longer needed.
**Risk Assessment:**
- Low risk: Changes maintain backward compatibility
- Fixes a critical display issue without introducing breaking changes
- Template blocks will have more predictable loading behavior
**Testing Suggestions:**
- Test block templates with complex linkage rules to ensure fields display correctly
- Verify that conditional field visibility works as expected in templates
- Check that form data loads consistently without field flickering
- Test various template scenarios to ensure stable field rendering
- Monitor network requests to confirm elimination of duplicate API calls
### Related issues
Fixes field visibility issues in block templates caused by duplicate API requests and data inconsistencies affecting linkage rule evaluation.
### Showcase
This fix resolves field visibility issues in block templates. Before the fix, fields would randomly not display due to inconsistent API responses affecting linkage rules. After the fix, fields display consistently as expected.
### Changelog
| Language | Changelog |
| ---------- | --------- |
| 🇺🇸 English | Fix fields not displaying in block templates caused by duplicate API requests |
| 🇨🇳 Chinese | 修复区块模板中因重复接口请求而导致的字段不显示问题 |
### Docs
| Language | Link |
| ---------- | --------- |
| 🇺🇸 English | |
| 🇨🇳 Chinese | |
### Checklists
- [x] All changes have been self-tested and work as expected
- [x] Test cases are updated/provided or not needed
- [x] Doc is updated/provided or not needed
- [x] Component demo is updated/provided or not needed
- [x] Changelog is provided or not needed
- [ ] Request a code review if it is necessary