8000 feat(input-stepper): add alignToStep property to align value with ste… by movrack · Pull Request #2511 · ing-bank/lion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(input-stepper): add alignToStep property to align value with ste… #2511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

movrack
Copy link
@movrack movrack commented Apr 25, 2025

Adding property alingToStep on input-stepper.
When property enabled, clicking on + or - button will verify the next step to reach and align on step multiple if user did enter custom value in between.

example
min 0
max 100
step 10
current value 55

click + ==> 60 instead of 65
click - ==> 50 instead of 55

if min is not 0:

min 3
max 100
step 10
current value 55

click + ==> 63 instead of 65
click - ==> 53 instead of 55

What I did

  1. Implement the property
  2. Add test
  3. Write documentation

I made multiple try with the changeset but I don't find how to do it correctly.

Copy link
changeset-bot bot commented Apr 25, 2025

🦋 Changeset detected

Latest commit: 233db85

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

This PR includes changesets to release 1 package
Name Type
@lion/ui 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

@CLAassistant
Copy link
CLAassistant commented Apr 25, 2025

CLA assistant check
All committers have signed the CLA.

const newValue = this.currentValue + step;
let newValue = this.currentValue + step;

if (this.alignToStep && (this.currentValue + min) % step !== 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This is native behaviour of the <input type="number">, so maybe we should not provide an option and just make this default. @ryubro @okadurin ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it makes better sense to me but we're introducing a break change. Maybe we should offer an option that is opposite to alignToStep, for those possible consumers who are using the current behavior as a feature?

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.

5 participants
0