Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Fix project.view.ts: change string columns ('2','1') to numbers (2,1)
- ModalForm: auto-upgrade modal size when sections have multi-column layout
- PercentField: add interactive slider control alongside number input
- Add 3 new tests for sections modal size auto-upgrade behavior
- Update ROADMAP.md with optimization item under P1.2
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot fix all 21:05:49.702 @object-ui/example-crm:build: › Error: EEXIT: 1 |
…spec type
The @objectstack/spec type expects form section columns as string literals
("1" | "2" | "3" | "4"), not numbers. ModalForm.tsx already uses Number()
conversion to handle both formats.
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes ModalForm responsive behavior by implementing automatic modal size upgrades based on section column configuration, adding interactive slider controls to PercentField, and fixing type mismatches in the project view configuration.
Changes:
- ModalForm now auto-upgrades modal size (e.g., to
max-w-2xl) when sections use multi-column layouts, enabling proper responsive grid rendering on tablets - PercentField gains an interactive Slider component for easier percentage/progress adjustment
- Type corrections in project.view.ts change section columns from string literals to numeric literals
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-form/src/ModalForm.tsx | Added section-aware modal size inference logic that examines max columns across sections and auto-upgrades dialog width accordingly; updated useMemo dependency array |
| packages/fields/src/widgets/PercentField.tsx | Integrated Slider component below the numeric input for interactive percentage control; includes accessibility attributes and respects readonly state |
| examples/crm/src/views/project.view.ts | Fixed section columns type from string literals ('2' as const) to numeric literals (2 as const) to match ModalFormSectionConfig type definition |
| packages/plugin-form/src/tests/MobileUX.test.tsx | Added 3 comprehensive test cases covering section auto-upgrade behavior: 2-column upgrade to lg, single-column stays default, explicit modalSize override |
| ROADMAP.md | Added completed item documenting the modal form responsive optimization under P1.2 Console Forms section |
| }; | ||
|
|
||
| const handleSliderChange = (values: number[]) => { | ||
| onChange(values[0] / 100); |
There was a problem hiding this comment.
The slider integration for PercentField lacks test coverage. Given that this repository has comprehensive test coverage for field widgets (as seen in packages/fields/src/tests/), the new slider functionality should be covered by unit tests. Consider adding tests that verify:
- Slider value synchronizes with input value
- Slider respects disabled/readonly state
- Slider changes trigger onChange callback correctly
- Edge cases like null values are handled properly
| onChange(values[0] / 100); | |
| // Do not propagate changes when field is readonly or disabled | |
| if (readonly || props.disabled) return; | |
| if (!Array.isArray(values) || values.length === 0) { | |
| // Mirror text input behavior: empty selection -> null value | |
| onChange(null as any); | |
| return; | |
| } | |
| const raw = values[0]; | |
| const nextValue = typeof raw === 'number' ? raw / 100 : null; | |
| onChange(nextValue as any); |
There was a problem hiding this comment.
Addressed in dc0fad3. Applied the suggested defensive checks in handleSliderChange (readonly/disabled guard, array validation, type-check before division). Also added 4 unit tests covering slider rendering, disabled state, readonly exclusion, and null value handling.
| onValueChange={handleSliderChange} | ||
| min={0} | ||
| max={100} | ||
| step={1} |
There was a problem hiding this comment.
The slider step is hardcoded to 1, but the input field respects the precision setting (defaulting to 2 decimal places). This creates a UX inconsistency where users can type 45.67% in the input, but the slider can only select whole number percentages. Consider making the slider step configurable based on precision, or at least use a smaller step (e.g., 0.1) to allow more granular control.
There was a problem hiding this comment.
Fixed in dc0fad3. Slider step now derives from precision (Math.pow(10, -precision)) — defaults to 0.01 matching the input's 2-decimal precision, instead of the hardcoded 1.
Fixed in 5df7bf3. The CRM build failure was caused by |
|
@copilot 21:41:28.241 ../../examples/crm/objectstack.config.ts(76,5): error TS2322: Type '{ name: string; label: string; description: string; objectName: string; type: string; columns: ({ field: string; label: string; aggregate?: undefined; } | { field: string; label: string; aggregate: string; })[]; groupingsDown: { ...; }[]; chart: { ...; }; }' is not assignable to type 'Omit<{ name: string; label: string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }; objectName: string; ... 8 more ...; performance?: { ...; } | undefined; }, "name"> & { ...; }'. |
…d step, and tests - handleSliderChange: add readonly/disabled guard, validate array input, type-check value before division - Slider step now derives from precision (default 0.01) instead of hardcoded 1, matching the input granularity - Add 4 unit tests: slider rendering, disabled state, readonly exclusion, null value handling Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
The |
ModalForm with sections stays at
default(max-w-lg) regardless of section column config, forcing single-column layout on tablets. Progress/percent fields lack interactive controls.ModalForm size auto-upgrade for sections (
ModalForm.tsx)When sections are present,
autoLayoutResultisnull(skipped intentionally), soeffectiveModalSizealways falls back to'default'. Added section-aware size inference:This triggers
max-w-2xlfor 2-column sections, enabling@md:grid-cols-2container queries. UsesNumber()conversion to handle both string ("2"from@objectstack/spec) and numeric (2fromModalFormSectionConfig) column values.PercentField slider control (
PercentField.tsx)Added a
<Slider>below the number input for interactive percent/progress editing. Includes:aria-label="Percentage"for accessibilityreadonlyanddisabledstatehandleSliderChangewith array validation and type-checking before divisionMath.pow(10, -precision), defaulting to0.01) matching the input's granularity instead of hardcoded1Tests
MobileUX.test.tsx: sections auto-upgrade tolg, single-column staysdefault, explicitmodalSizeoverrides auto-upgraderemaining-widgets.test.tsx: slider rendering, disabled state, readonly exclusion, null value handlingROADMAP
Added completed item under P1.2 (Console — Forms & Data Collection).
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.