Skip to content

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

@vercel
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
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.

@sean-perkins sean-perkins marked this pull request as ready for review August 30, 2024 16:57
@sean-perkins sean-perkins requested a review from a team as a code owner August 30, 2024 16:57
Copy link
Contributor

@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
@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

Development

Successfully merging this pull request may close these issues.

bug: ion-range emit value 'NaN' when dragging to the far left end of the screen when the browser is full screen

3 participants