Fix float document editor step validation#2945
Conversation
WalkthroughThe integer column type component was modified to support both integer and float column types. The exported Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR extends
Confidence Score: 3/5Not safe to merge as-is — the step change blocks editing of high-precision float values already stored in the database. The PR contains one P1 regression: replacing step="any" with step=0.001 causes browser step-mismatch validation failures for any float/double value with more than 3 decimal places, breaking the primary user path of editing existing float document values. The fix is a one-word change, but it must be made before merging. src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte — line 31 Important Files Changed
Reviews (1): Last reviewed commit: "Fix float document editor step validatio..." | Re-trigger Greptile |
| max={column.max} | ||
| required={column.required} | ||
| step={column.type === 'double' ? 'any' : 1} | ||
| step={isDecimalColumn ? FLOAT_INPUT_STEP : 1} |
There was a problem hiding this comment.
step="0.001" breaks high-precision float input
Changing from step="any" to FLOAT_INPUT_STEP (0.001) means the browser's native step-mismatch validation will reject any value that isn't an exact multiple of 0.001. This breaks editing of double/float documents that contain values with more than 3 decimal places (e.g. 3.14159265, 1.23456789). The old step="any" was intentionally unrestricted and was the correct choice for arbitrary-precision floating-point columns.
With step="any" the stepMismatch validity flag is never set and any number (satisfying min/max) is accepted. With step="0.001" the browser rejects values like 1.2345 with a stepMismatch error, blocking form submission entirely.
| step={isDecimalColumn ? FLOAT_INPUT_STEP : 1} | |
| step={isDecimalColumn ? 'any' : 1} |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte (1)
12-12: Align float/doublestepwith existing project convention.Line 12 and Line 31 use
0.001; the established Console pattern for float/doubleInputNumberisstep={0.1}. Please keep this consistent across editors.Suggested alignment
- const FLOAT_INPUT_STEP = 0.001; + const FLOAT_INPUT_STEP = 0.1;Based on learnings: "In the Appwrite Console codebase, for float/double column inputs in database table column configuration files (like float.svelte), use step={0.1} for InputNumber components, not step='any'."
Also applies to: 31-31
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte at line 12, The FLOAT_INPUT_STEP constant is set to 0.001 but should follow the Console convention of 0.1 for float/double InputNumber fields; update the FLOAT_INPUT_STEP declaration and any InputNumber usages that reference it (e.g., the constant FLOAT_INPUT_STEP and the InputNumber components in this file) to use 0.1 so the step prop becomes step={FLOAT_INPUT_STEP} (i.e., 0.1) consistently across the editor.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte:
- Line 16: The float column type is not routed to the integer row-editor, so
update the dispatcher mapping in column.svelte: add the entry `float: Integer`
to the columnsTypeMap (the same map that currently contains `double: Integer`)
so Models.ColumnFloat columns are handled; this ensures the component logic
around `$: isDecimalColumn = ['double', 'float'].includes(column.type as
string);` and the integer.svelte row editor are reachable for float columns.
---
Nitpick comments:
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte:
- Line 12: The FLOAT_INPUT_STEP constant is set to 0.001 but should follow the
Console convention of 0.1 for float/double InputNumber fields; update the
FLOAT_INPUT_STEP declaration and any InputNumber usages that reference it (e.g.,
the constant FLOAT_INPUT_STEP and the InputNumber components in this file) to
use 0.1 so the step prop becomes step={FLOAT_INPUT_STEP} (i.e., 0.1)
consistently across the editor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f9c3e443-b910-4aa2-b179-98084208e404
📒 Files selected for processing (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte
|
|
||
| $: autofocus = limited; | ||
| $: nullable = !limited ? !column.required : false; | ||
| $: isDecimalColumn = ['double', 'float'].includes(column.type as string); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Locate the files mentioned in the review
find . -name "integer.svelte" -path "*/rows/columns/types/*" 2>/dev/null
find . -name "column.svelte" -path "*/rows/columns/*" 2>/dev/null
find . -name "float.svelte" -path "*/rows/columns/types/*" 2>/dev/nullRepository: appwrite/console
Length of output: 308
🏁 Script executed:
#!/bin/bash
# Check the actual line 16 in integer.svelte
FILE="src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte"
if [ -f "$FILE" ]; then
cat -n "$FILE" | head -20
else
echo "File not found at expected path"
fiRepository: appwrite/console
Length of output: 854
🏁 Script executed:
#!/bin/bash
# Search for column.svelte in rows/columns directory
find . -name "column.svelte" -type f 2>/dev/null | grep -E "rows/columns" | head -5Repository: appwrite/console
Length of output: 180
🏁 Script executed:
#!/bin/bash
# Read the column.svelte dispatcher
FILE="src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/column.svelte"
cat -n "$FILE"Repository: appwrite/console
Length of output: 3540
🏁 Script executed:
#!/bin/bash
# Check if float.svelte exists in types directory
find . -path "*/rows/columns/types/float.svelte" 2>/dev/nullRepository: appwrite/console
Length of output: 42
🏁 Script executed:
#!/bin/bash
# Also search for any float.svelte in the databases area
find . -name "float.svelte" -path "*/databases/*" 2>/dev/nullRepository: appwrite/console
Length of output: 174
🏁 Script executed:
#!/bin/bash
# Search for float references in rows/columns directory
rg "float" src/routes/\(console\)/project-\*-/databases/database-\*/table-\*/rows/columns/ --type svelte -iRepository: appwrite/console
Length of output: 90
🏁 Script executed:
#!/bin/bash
# Check the float.svelte in columns directory to understand the pattern
FILE="src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/float.svelte"
cat -n "$FILE" | head -30Repository: appwrite/console
Length of output: 1215
🏁 Script executed:
#!/bin/bash
# Search for float references in rows/columns directory without type filter
rg "float" "src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/"Repository: appwrite/console
Length of output: 616
🏁 Script executed:
#!/bin/bash
# Check if there are any other column type files that might handle float
ls -la "src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/"Repository: appwrite/console
Length of output: 879
Float column type is not mapped in the row editing dispatcher, making the float check unreachable.
The component at line 16 checks for float: $: isDecimalColumn = ['double', 'float'].includes(column.type as string);, and integer.svelte accepts Models.ColumnFloat (line 10), but the dispatcher in column.svelte only maps double: Integer without mapping float. This causes float columns to fail rendering in the rows context since there is no separate float.svelte for row editing.
Add float: Integer to the columnsTypeMap in column.svelte to route float columns to the integer component.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte
at line 16, The float column type is not routed to the integer row-editor, so
update the dispatcher mapping in column.svelte: add the entry `float: Integer`
to the columnsTypeMap (the same map that currently contains `double: Integer`)
so Models.ColumnFloat columns are handled; this ensures the component logic
around `$: isDecimalColumn = ['double', 'float'].includes(column.type as
string);` and the integer.svelte row editor are reachable for float columns.
|
Opened a fix in the Console repo: #2945 This updates the row/document editor numeric input to use an explicit decimal step for float fields so values like |
What does this PR do?
Fixes float input validation in the row/document editor by using an explicit decimal step for float fields.
Test Plan
Code-path verification:
step={0.001}step={1}Expected behavior:
1.23should no longer fail browser step validation in the document editorRelated PRs and Issues
Fixes #11657
Have you read the Contributing Guidelines on issues?
Yes.