-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
FocalPointPicker: Convert to TypeScript #43872
Conversation
Size Change: +86 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
value: Parameters< UnitControlOnChangeCallback >[ 0 ], | ||
axis: FocalPointAxis | ||
) => { | ||
if ( value === undefined ) return; |
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.
Return early because TS doesn't want an undefined value passed to parseInt
. The result is the same though, so shouldn't be considered a runtime change.
const [ bounds, setBounds ] = useState( INITIAL_BOUNDS ); | ||
const refUpdateBounds = useRef( () => { | ||
if ( ! dragAreaRef.current ) return; |
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.
The rest of this function doesn't work if the ref is unset.
| 'dragDirection' | ||
| 'hideLabelFromVision' | ||
| 'labelPosition' | ||
| 'prefix' | ||
| '__next36pxDefaultSize' |
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.
UnitControl was missing some props.
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.
We can probably wait for the NumberControl
refactor to TypeScript to land first, and then rebase?
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.
Good call 👍
@@ -161,6 +235,7 @@ export default function FocalPointPicker( { | |||
|
|||
return ( | |||
<BaseControl | |||
{ ...restProps } |
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.
409bf9f
to
7267149
Compare
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.
Looking good so far!
// @ts-expect-error: TODO: Is this parseFloat necessary? | ||
x: roundToTwoDecimalPlaces( parseFloat( resolvedValue.x ) ), | ||
// @ts-expect-error: TODO: Is this parseFloat necessary? | ||
y: roundToTwoDecimalPlaces( parseFloat( resolvedValue.y ) ), |
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 doesn't look like — let's remove it and see if we get any unexpected behavior from unit tests / manual regression testing.
Otherwise, @stokesman may also have some additional context ?
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.
PR is looking good 🚀 only #43872 (comment) are #43872 (comment) still need to be addressed
Since this changes some of the UnitControl
types, it definitely has some overlap with the NumberControl
TypeScript refactor. Up to you about which PR you'd rather merge first, and which one you'd rather rebase + solve conflicts in
08a71e9
to
f709d34
Compare
Part of #35744
In preparation for #38730
What?
Converts FocalPointPicker to TypeScript. To limit the scope of this PR, tests have not been touched.
Why?
Better docs and devex.
Testing Instructions
npm run storybook:dev
and see the FocalPointPicker stories in Docs view.✅ Type checks pass