Add Airtable-like Filter Builder Component with Advanced Field Types#14
Conversation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot 继续 |
There was a problem hiding this comment.
Pull request overview
This PR implements an Airtable-like filter builder component for Object UI, providing a schema-driven interface for creating complex query conditions with dynamic field selection and type-aware operators.
Changes:
- Added FilterBuilder UI component with support for dynamic conditions, AND/OR logic, and field-type aware operators
- Integrated component with Object UI's schema system via renderer and metadata
- Created comprehensive documentation and interactive demo
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/ui/filter-builder.tsx | Core FilterBuilder component implementation with condition management and operator logic |
| packages/components/src/ui/index.ts | Export statement for new FilterBuilder component |
| packages/components/src/renderers/complex/filter-builder.tsx | Schema renderer integration for FilterBuilder with ComponentRegistry |
| packages/components/src/renderers/complex/index.ts | Import statement for filter-builder renderer |
| packages/components/metadata/FilterBuilder.component.yml | Component metadata defining props, events, and features |
| packages/components/docs/FilterBuilder.md | Comprehensive documentation with usage examples and API reference |
| examples/prototype/src/main.tsx | URL parameter routing to support filter-builder demo |
| examples/prototype/src/FilterBuilderDemo.tsx | Demo page showcasing three filter builder examples |
| React.useEffect(() => { | ||
| if (value && JSON.stringify(value) !== JSON.stringify(filterGroup)) { | ||
| setFilterGroup(value) | ||
| } | ||
| }, [value]) |
There was a problem hiding this comment.
The useEffect dependency array is missing filterGroup, which can cause stale closure issues. When filterGroup changes internally, the comparison on line 63 will use the old value, potentially causing infinite loops or missed updates.
There was a problem hiding this comment.
Fixed in commit d5d2b84. Added filterGroup to the useEffect dependency array to prevent stale closure issues.
There was a problem hiding this comment.
The original implementation was correct. Adding filterGroup to the dependency array would cause an infinite loop since the effect updates filterGroup. The JSON.stringify comparison already prevents stale closures by comparing the actual values. No change needed for this.
|
|
||
| const addCondition = () => { | ||
| const newCondition: FilterCondition = { | ||
| id: `condition-${crypto.randomUUID()}`, |
There was a problem hiding this comment.
The ID generation combines a prefix with a UUID, making it unnecessarily long. Consider using just crypto.randomUUID() directly, as UUIDs are already guaranteed to be unique.
| id: `condition-${crypto.randomUUID()}`, | |
| id: crypto.randomUUID(), |
There was a problem hiding this comment.
Fixed in commit d5d2b84. Simplified ID generation to use crypto.randomUUID() directly without the unnecessary prefix.
…nced input types Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
已完成增强功能!我添加了以下新特性: 新增功能:
支持的字段类型:
提交记录:9b7358e |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot 修正所有 |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
已修复所有问题! 修复内容:
提交记录:d5d2b84
已修复!只修复了 UUID 生成问题: 修复内容: 关于 useEffect 依赖问题: 提交记录:750b2cb |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
✅ All checks passed!
|
|
✅ All checks passed!
|

Implementation: Airtable-like Filter Component ✅
Successfully implemented an Airtable-like filter builder component for Object UI with full schema-driven configuration and interactive features.
✅ Completed Tasks
packages/components/src/ui/filter-builder.tsx)📸 Screenshots
Enhanced Filter Builder with Advanced Features
The screenshot shows:
Original Filter Builder Demo
Interactive Features (Dropdown Open)
✨ Features Implemented
✅ Dynamic Filter Conditions - Add and remove filter conditions dynamically
✅ Field Selection - Select from available fields with dropdown
✅ Type-Aware Operators - Operators change based on field type (text, number, boolean, date, select)
✅ Value Input - Smart input fields that adapt to field type:
✅ AND/OR Logic Toggle - Switch between AND and OR logic when multiple conditions exist
✅ Clear All Button - Quick way to remove all filters at once
✅ Schema-Driven - Fully configurable via JSON schema
✅ Tailwind Styled - Consistent with Object UI design system
✅ Shadcn Components - Built with Radix UI primitives
📦 Component API
Schema Definition
Basic Usage:
With Select Fields:
With Date Fields:
Supported Field Types
Supported Operators
🔧 Code Quality Improvements
crypto.randomUUID()directly for ID generation (removed unnecessary prefix)📚 Documentation
packages/components/docs/FilterBuilder.md🧪 Testing
To view the demo locally:
pnpm --filter prototype dev # Visit http://localhost:5173/?demo=filter-builder🔍 Security Summary
✅ No vulnerabilities detected by CodeQL scanner
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.