Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: Allow updating its value while dragging. #38247
FocalPointPicker: Allow updating its value while dragging. #38247
Changes from 17 commits
8705154
f41d120
467f3a3
5ed3b2e
4aac1f6
95cb4b4
3119b56
54d8cc0
b82a001
7205351
f74c789
541c658
720a1c6
518475a
6d62ff0
40f9e9e
3bd8847
9ac9517
9ea5d61
38c6446
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Q: when checking this test on my local machine, I tried to make the test fail by modifying the
resolvePoint
function toThe test fails (as expected), but the values received by the
onChange
spy are notx: 0.25, y: 0.25
, but instead arex: 0, y: 0
. I wasn't expecting this behaviour, do you know why would this happen?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.
My guess is that the main reason is that the picker doesn't have width and height props. Also, fireEvent is called without any other parameters but am not sure if the case would be the same if the picker had set dimensions.
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.
Ok, so I haven't been able to use
mouseMove
to create a proper emulation of a user interaction. However, I managed that by usingfireEvent.keyDown( dragArea, { charCode: 0, keyCode: 38 } );
which triggers onChange with an "expected" value ofx: 0.25, y: 0.24
making my test fail. That was because onChange was called with the same valueupdateValue
would received.I added a second parameter to the
updateValue
method which is a callback that is passed to the setState call. Moving theonChange
call inside that callback fixed the issue and made the test pass. Everything looks fine now.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.
Thank you for the explanation, makes sense!
I suggest we add another unit test to check this
onChange
baheviour: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 not sure I understand what you're asking for. Doesn't the initial test cover this behaviour? Do you want me to remove the onChange part from that test and then make another one in the
controllability
section that only tests the onChange part?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 proposing to add another unit test aimed at testing the behaviour that I highlighted earlier and you fixed in your latest commits by using the
setState
callback to callonChange
.Earlier, when removing
resolvePoint
from this test, theonChange
spy was receivingx: 0, y: 0
instead of the expected value. Thanks to your fix, theonChange
would now receive the correct values. My proposal is to add an additional unit test to specifically test that (note that, in the new test, theresolvePoint
prop is not specified)Hope I managed to explain myself better :)
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'll add the unit test but I want to make sure we're on the same page.
By using
mouseDown
andmouseMove
we still receive { x: 0.00, y: 0.00 } instead of the values with which the picker is initialised.The bug that was fixed by moving the onChange inside the setState callback was related to the
resolvePoint
prop.This unit test becomes a test to future proof the keyboard interaction (rather for the UP key press). Am I right?
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 see, I missed that detail. Do you think it's worth investigating this in a follow-up PR?