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 #6101: Slider: event.value in onSlideEnd returns null on touch devices #6104

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

kl-nevermore
Copy link
Contributor

Fix #6101

  • The event of touchend does not contain touches
  • Use changedTouches with reference to MUI
  • query via caniuse is not supported on safari
    • but tested in iOS17 and iOS15.8, it worked

Copy link

vercel bot commented Mar 7, 2024

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

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Mar 7, 2024 1:03pm
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Mar 7, 2024 1:03pm

@melloware
Copy link
Member

@kl-nevermore can you try this more concise version?

const trackTouch = (event) => {
    const changedTouch = event.changedTouches?.find(touch => touch.identifier === touchId.current);

    if (changedTouch) {
        return {
            pageX: changedTouch.pageX,
            pageY: changedTouch.pageY
        };
    }

    return {
        pageX: event.pageX,
        pageY: event.pageY
    };
};

@@ -156,11 +163,32 @@ export const Slider = React.memo(
barHeight.current = elementRef.current.offsetHeight;
};

const trackFinger = (event) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const trackFinger = (event) => {
const trackTouch= (event) => {

@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Mar 7, 2024
@kl-nevermore
Copy link
Contributor Author

@kl-nevermore can you try this more concise version?

const trackTouch = (event) => {
    const changedTouch = event.changedTouches?.find(touch => touch.identifier === touchId.current);

    if (changedTouch) {
        return {
            pageX: changedTouch.pageX,
            pageY: changedTouch.pageY
        };
    }

    return {
        pageX: event.pageX,
        pageY: event.pageY
    };
};

it is a TouchList
image

@melloware
Copy link
Member

OK then just rename to trackTouch and I think we are good.

@kl-nevermore
Copy link
Contributor Author

maybe?

 const trackTouch = (_event) => {
            const event = Array.from(_event.changedTouches ?? []).find((t) => t.identifier === touchId.current) || _event;

            return {
                pageX: event.pageX,
                pageY: event.pageY
            };
        };

@melloware
Copy link
Member

Oooh I like it!

@melloware
Copy link
Member

or reverse it called the param event and the private variable const _event ?

@kl-nevermore
Copy link
Contributor Author

Updated

@melloware melloware changed the title Fix:Slider: event.value in onSlideEnd returns null on touch devices Fix #6101: Slider: event.value in onSlideEnd returns null on touch devices Mar 7, 2024
@nitrogenous nitrogenous requested a review from gucal March 14, 2024 06:23
@nitrogenous
Copy link
Contributor

superb

@nitrogenous nitrogenous merged commit 4c5a93c into primefaces:master Mar 18, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slider: Null event.value within the onSlideEnd
3 participants