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(ColorPicker): apply s and b of previous hsb to hsbValue #6788

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

KumJungMin
Copy link
Contributor

@KumJungMin KumJungMin commented Jun 24, 2024

Defect Fixes


modified list

  1. pageYOffset is deprecated, So I changed pageYOffset to scrollY
// before
const top = hueViewRef.current.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
// after
const top = hueViewRef.current.getBoundingClientRect().top + (window.scrollY || document.documentElement.scrollTop || document.body.scrollTop || 0);

  1. check undefined in Y position.
const getPositionY = (event) => {
  if (event.pageY !== undefined) return event.pageY;
  else if (event.touches !== undefined) return event.touches[0].pageY;
  else return 0;
};

  1. apply s and b of previous hsb to this.hsbValue
// before
hsbValue.current = validateHSB({
    h: Math.floor((360 * (150 - Math.max(0, Math.min(150, (event.pageY || event.changedTouches[0].pageY) - top)))) / 150),
    s: 100, // this!
    b: 100, // this!
});
// after
hsbValue.current = validateHSB({
    h: hue,
    s: hsbValue.current.s, // changed code
    b: hsbValue.current.b // changed code
});

result

2024-06-24.9.21.55.mov

Copy link

vercel bot commented Jun 24, 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 Jun 25, 2024 0:05am
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 0:05am

@KumJungMin KumJungMin changed the title Fix(ColorPicker): apply s and b of previous hsb to this.hsbValue Fix(ColorPicker): apply s and b of previous hsb to hsbValue Jun 24, 2024
@@ -97,13 +97,21 @@ export const ColorPicker = React.memo(
!isUnstyled && DomHandler.addClass(elementRef.current, 'p-colorpicker-dragging');
};

const getPositionY = (event) => {
if (event.pageY !== undefined) return event.pageY;
else if (event.touches !== undefined) return event.touches[0].pageY;
Copy link
Member

Choose a reason for hiding this comment

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

should this be touches or changedTouches ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OOPS!! you're right
thank you for comment :) (63881b0)

@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Jun 24, 2024
@KumJungMin KumJungMin requested a review from melloware June 25, 2024 00:07
@melloware melloware merged commit da22444 into primefaces:master Jun 25, 2024
5 checks passed
@KumJungMin KumJungMin deleted the fix/issue-6787 branch June 25, 2024 00:29
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.

ColorPicker: the selected color is change to hug line color
2 participants