Skip to content

fix: prevent numeric input from resetting to zero on blur without edit#7560

Open
3351163616 wants to merge 1 commit intoAstrBotDevs:masterfrom
3351163616:fix/numeric-input-blur-reset
Open

fix: prevent numeric input from resetting to zero on blur without edit#7560
3351163616 wants to merge 1 commit intoAstrBotDevs:masterfrom
3351163616:fix/numeric-input-blur-reset

Conversation

@3351163616
Copy link
Copy Markdown

@3351163616 3351163616 commented Apr 14, 2026

Summary

  • Fix numeric input fields (e.g., kb_fusion_top_k, kb_final_top_k) resetting to 0 when focused and blurred without editing
  • Root cause: @blur handler in ConfigItemRenderer.vue called toNumber(null) when numericTemp was never set (no edits), and parseFloat(null)NaN → fallback to 0
  • Fix: skip emitting update when numericTemp is null (user made no changes), only reset numericTemp to null

Test plan

  • Open config page with numeric fields (e.g., knowledge base settings with "融合检索结果数" = 20)
  • Click the numeric input to focus it, then click outside without editing → value should remain 20 (not reset to 0)
  • Edit the value (e.g., change 20 to 10), then click outside → value should update to 10
  • Verify slider + text-field combo still works correctly for numeric fields with sliders

Summary by Sourcery

Bug Fixes:

  • Avoid emitting numeric value updates on blur when the temporary numeric value was never modified, preventing fields from resetting to zero on focus/blur without edits.

When a numeric input field was focused but not edited, the blur handler
called toNumber(null) which returned 0 via parseFloat(null) → NaN → 0.
Now we skip emitting the update when numericTemp is null (no edits made).
@auto-assign auto-assign bot requested review from Fridemn and Raven95676 April 14, 2026 15:43
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider extracting the inline @blur arrow function into a named method to keep the template simpler and make the blur/update logic easier to unit test and extend later.
  • If numericTemp is only ever null or a string/number, you could simplify the check by using a stricter comparison (numericTemp !== null) or, alternatively, document that numericTemp may be undefined so the != null check is clearly intentional.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the inline `@blur` arrow function into a named method to keep the template simpler and make the blur/update logic easier to unit test and extend later.
- If `numericTemp` is only ever `null` or a string/number, you could simplify the check by using a stricter comparison (`numericTemp !== null`) or, alternatively, document that `numericTemp` may be `undefined` so the `!= null` check is clearly intentional.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the ConfigItemRenderer.vue component to include a null check for numericTemp within the @blur event handler of the numeric text field. This change ensures that emitUpdate is only called when a value has been entered, preventing potential issues with null values being processed. I have no feedback to provide as there were no review comments to evaluate.

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

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant