Skip to content

Conversation

@tcrundall-tng
Copy link
Collaborator

UIEXT-2930 (Add configurable step size to NumberInputWidget)

Copilot AI review requested due to automatic review settings November 12, 2025 09:55
@tcrundall-tng tcrundall-tng requested review from a team as code owners November 12, 2025 09:55
@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: e07d7ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@knime/components Patch
@knime/jsonforms Patch
@knime/hub-features Patch
@knime/rich-text-editor Patch
@knime/ui-extension-renderer Patch
@knime/virtual-tree Patch
demo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for configurable step sizes in number input widgets by introducing a stepSize option in the UI schema. Previously, step sizes were hardcoded based on the input type (integer or double). Now users can override the default behavior by specifying a custom step size in the UI schema options.

Key changes:

  • Added stepSize option support in the UI schema for NumberControlBase
  • Implemented custom step size prop in NumberInput component with fallback to defaults
  • Improved rounding logic to handle arbitrary step sizes without precision errors

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/jsonforms/src/uiComponents/NumberControlBase.vue Added stepSize option reading from UI schema and converted stepSize to computed property
packages/components/src/components/forms/NumberInput/NumberInput.vue Added step prop to NumberInput component and improved rounding logic for arbitrary step sizes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tcrundall-tng tcrundall-tng force-pushed the enh/UIEXT-2930-make-number-widget-stepsize-configurable branch from 8410f0c to cc8a56e Compare November 12, 2025 10:00
Copilot AI review requested due to automatic review settings November 12, 2025 10:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

UIEXT-2930 (Add configurable step size to NumberInputWidget)
@tcrundall-tng tcrundall-tng force-pushed the enh/UIEXT-2930-make-number-widget-stepsize-configurable branch from c4a1386 to ef7ca64 Compare November 12, 2025 10:36
@tcrundall-tng
Copy link
Collaborator Author

⚠️ No Changeset found

Latest commit: ef7ca64

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

I need to do this.

UIEXT-2930 (Add configurable step size to NumberInputWidget)
Copilot AI review requested due to automatic review settings November 18, 2025 19:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

:type="type"
:min="minParams?.min"
:max="maxParams?.max"
:step="stepSize"
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

The step prop is being passed the computed ref object instead of its value. Change :step=\"stepSize\" to :step=\"stepSize.value\" to pass the actual number value.

Suggested change
:step="stepSize"
:step="stepSize.value"

Copilot uses AI. Check for mistakes.
/** Mimic stepping to nearest step with safe value rounding */
let parsedVal = value + increment;
parsedVal = Math.round(parsedVal * 10) / 10; // eslint-disable-line no-magic-numbers
let scaleFactor = 1 / Math.abs(increment); // eslint-disable-line no-magic-numbers
Copy link

Choose a reason for hiding this comment

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

can we be sure that increments are never zero?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True. Currently the increment is only ever the stepsize.
I've added an extra check that if step is ever 0 then stepSize uses the default.

let scaleFactor = 1 / Math.abs(increment); // eslint-disable-line no-magic-numbers
if (Math.abs(increment) < 1) {
// Avoid rounding errors induced by fractional increments
scaleFactor = Math.round(scaleFactor);
Copy link

Choose a reason for hiding this comment

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

if increment < 0.5, then scaleFactor will be rounded to 0, right? Won't we have a division by zero in line 220 then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not quite. If increment < 0.5, scaleFactor > 2.

If increment > 2, scaleFactor < 0.5, but then we wouldn't be in this if block.

/** Mimic stepping to nearest step with safe value rounding */
let parsedVal = value + increment;
parsedVal = Math.round(parsedVal * 10) / 10; // eslint-disable-line no-magic-numbers
Copy link

Choose a reason for hiding this comment

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

what was wrong with this old logic / why did we add the scaleFactor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was hardcoded to a maximum precision of 1 decimal place. So a step interval of 0.001 would be treated as 0.1.

But there are other issues in my current implementation as you've pointed out. I'll fix it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I (and claude) added some unit tests which can double as quasi-documentation of expected behavior.

UIEXT-2930 (Add configurable step size to NumberInputWidget)
UIEXT-2930 (Add configurable step size to NumberInputWidget)
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.

2 participants