-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
RangeControl: Fix Reset and initialPosition #20247
Conversation
.emotion-10 { | ||
.emotion-18 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we worry about how unstable these incrementing IDs are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to be observe I think 👍
To be honest, I've never used Storybook Snapshots together with Emotion prior to this project.
These updates snapshot changes make sense, as a push I made directly affect the styles that are computed/generated, which I suppose, affects the number of IDs that need to be incremented.
@@ -48,6 +48,7 @@ const BaseRangeControl = forwardRef( | |||
allowReset = false, | |||
beforeIcon, | |||
className, | |||
currentInput, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused. What is this prop? Why is it needed? How do we document it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest... I'm not sure. But it was from the original RangeControl
before the refactor 🙃 . I brought it back to preserve the value logic it had
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nor used or documented in Gutenberg so maybe we can pretend it was never there and forget about it?
Size Change: +4.49 kB (0%) Total Size: 866 kB
ℹ️ View Unchanged
|
Merged the latest! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There is this issue with the tooltips I mentioned in my previous comment that should be improved but it isn't a blocker in my opinion. It's a minor inconvenience.
You also should decide what to do about currentInput
that seems unnecessary.
|
||
useEffect( () => { | ||
if ( valueRef.current !== valueProp ) { | ||
setClampValue( valueProp ); | ||
valueRef.current = valueProp; | ||
} | ||
}, [ valueProp, setClampValue ] ); | ||
}, [ valueRef, valueProp, setValue ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't immediately recall where the conversation, but I have some recollection of discussing that it may be a concern to include a useRef
variable as a dependency of another hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, found it here: #20219 (comment)
So that hovering on a tooltip no longer keeps it open
Thanks for the reviews! Merging this up! |
* RangeControl: Fix reset and initialPosition logic * Add tests for desired initialPosition, value, and reset scenarios * Update storybook snapshots * Fix null value fill for marks * Remove unnecessary ref dependency in useEffect hook * Adjust Range x Tooltip interactions So that hovering on a tooltip no longer keeps it open
Description
This update is a followup to the recently updated
RangeControl
.It resolves how values are outputted based on
initialPosition
, external/internalvalue
, and Reset handling.These are some scenarios this update resolves:
If there is no
value
,initialPosition
, orcurrentInput
, the slider should appear to be centered, with nothing showing in the NumberInput.If there is an
initialPosition
andvalue
defined, it should usevalue
.If a reset action occurs, it will default to using
null
value. However, if the parent component uses an alternative value, it will resolve to that instead.How has this been tested?
Screenshots
The above GIF showcases the initial render with no defined values, resulting in a slider that's appears 50% filled. After adjusting the values, clicking reset will shift it back to 50%.
Types of changes
Takes care of some of the issues describe:
#20236 (comment)
Checklist:
Thank you! 🙏