Skip to content

Fix float document editor step validation#2945

Open
yug005 wants to merge 1 commit intoappwrite:mainfrom
yug005:codex/fix-float-document-editor-step
Open

Fix float document editor step validation#2945
yug005 wants to merge 1 commit intoappwrite:mainfrom
yug005:codex/fix-float-document-editor-step

Conversation

@yug005
Copy link
Copy Markdown

@yug005 yug005 commented Mar 29, 2026

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:

  • updated the row/document editor numeric input path
  • float/double fields now use step={0.001}
  • integer fields still use step={1}

Expected behavior:

  • values like 1.23 should no longer fail browser step validation in the document editor

Related PRs and Issues

Fixes #11657

Have you read the Contributing Guidelines on issues?

Yes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

Walkthrough

The integer column type component was modified to support both integer and float column types. The exported column prop type was expanded to accept Models.ColumnInteger | Models.ColumnFloat. A new reactive isDecimalColumn flag was introduced that evaluates to true when the column type is 'double' or 'float'. The InputNumber component's step prop logic was updated to use 0.001 for decimal columns and 1 for others, replacing the previous conditional that used 'any' for double types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix float document editor step validation' directly relates to the changeset, which modifies the integer.svelte component to handle both integer and float column types with appropriate step values for input validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 29, 2026

Greptile Summary

This PR extends integer.svelte to handle both integer and float/double column types by widening the prop type to Models.ColumnInteger | Models.ColumnFloat and introducing an isDecimalColumn reactive variable. The core intent is sound: the old code only checked column.type === 'double', missing the float type. However, the fix inadvertently introduces a regression by replacing the previously used step=\"any\" with a fixed step=0.001 — which restricts float/double inputs to at most 3 decimal places via browser step-mismatch validation, preventing users from editing high-precision values already stored in their database.

  • ✅ Widening the prop type to Models.ColumnInteger | Models.ColumnFloat is correct, as double-type columns are typed as ColumnFloat in the SDK.
  • ✅ Adding 'float' alongside 'double' to isDecimalColumn improves coverage.
  • step=0.001 replaces step=\"any\" and will cause browser validation to reject any float value whose decimal portion is not a multiple of 0.001 (e.g. 3.14159265). The original step=\"any\" was intentionally unrestricted and should be preserved for decimal column types."

Confidence Score: 3/5

Not 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

Filename Overview
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/columns/types/integer.svelte Adds ColumnFloat to the type union and introduces isDecimalColumn to cover both 'double' and 'float' column types, but replaces step="any" with step=0.001, unintentionally restricting float/double inputs to 3 decimal places.

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}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Suggested change
step={isDecimalColumn ? FLOAT_INPUT_STEP : 1}
step={isDecimalColumn ? 'any' : 1}

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/double step with existing project convention.

Line 12 and Line 31 use 0.001; the established Console pattern for float/double InputNumber is step={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

📥 Commits

Reviewing files that changed from the base of the PR and between 00d9765 and 33accfd.

📒 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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/null

Repository: 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"
fi

Repository: 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 -5

Repository: 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/null

Repository: 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/null

Repository: 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 -i

Repository: 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 -30

Repository: 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.

@yug005
Copy link
Copy Markdown
Author

yug005 commented Mar 29, 2026

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 1.23 no longer fail browser validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant