Skip to content
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

fix(range): emit correct value when knob is at start of bar #29820

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

sean-perkins
Copy link
Contributor

Issue number: resolves #29792


What is the current behavior?

When the user drags the range knob (most easily reproduced in fullscreen mode) and the gesture emits a current x position of 0, the range incorrectly emits a value of NaN.

What is the new behavior?

  • ion-range does not emit NaN and instead emits the correct range value for the knob

Does this introduce a breaking change?

  • Yes
  • No

Other information

Copy link

vercel bot commented Aug 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 4:57pm

@github-actions github-actions bot added the package: core @ionic/core package label Aug 30, 2024
@@ -449,7 +449,7 @@ export class Range implements ComponentInterface {
*/
private onEnd(detail: GestureDetail | MouseEvent) {
const { contentEl, initialContentScrollY } = this;
const currentX = (detail as GestureDetail).currentX || (detail as MouseEvent).clientX;
const currentX = (detail as GestureDetail).currentX ?? (detail as MouseEvent).clientX;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem here was that detail.currentX can evaluate to 0 and 0 || detail.clientX will treat the 0 as falsy and return the detail.clientX which is undefined.

Instead we wanted to take the currentX or take the clientX if the value is null/undefined.

Copy link
Member

@tanner-reits tanner-reits left a comment

Choose a reason for hiding this comment

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

Easy fix!

@sean-perkins sean-perkins added this pull request to the merge queue Aug 30, 2024
Merged via the queue into main with commit 6a3d7c7 Aug 30, 2024
48 checks passed
@sean-perkins sean-perkins deleted the sp/range-event branch August 30, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
2 participants