Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Make spinbox trigger changed after setValue #1960

Merged
merged 2 commits into from
May 3, 2017
Merged

Make spinbox trigger changed after setValue #1960

merged 2 commits into from
May 3, 2017

Conversation

vargasd
Copy link
Contributor

@vargasd vargasd commented Apr 17, 2017

After programmatically setting the value of the spinbox, the previous
value would be retained in the lastValue property of the control,
causing the "changed" event not to get triggered if the user were to
enter the previous value again. To avoid this, the current setValue
method was converted into a private method with an additional parameter
to set the last value, and the public method will wrap this and pass
that parameter, while internal uses of the method will use the private
method to avoid other side effects.

Fixes #1950

@futuremint
Copy link
Contributor

@vargasd please look into the failing unit test and ensure they are all passing.

@vargasd
Copy link
Contributor Author

vargasd commented Apr 19, 2017

Should I open another PR to fix the failing unit tests? They were previously broken and don't relate to this issue.

$spinbox.spinbox('setValue', '2');

$spinbox.on('changed.fu.spinbox', function () {
assert.ok(true, 'spinbox triggers changed after input' );
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not even getting validated. You need to use assert.async in here and call it to ensure this assertion gets asserted. This is an async test, so you need to tell QUnit it is async.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't asynchronous. The handler should be called synchronously on the focusout. I can make it asynchronous, but then the failure would happen because of a timeout rather than a 0-assertion test. I prefer the latter because it means the tests run more quickly, but I can change it if you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine for now but for future reference when using an event listener an async test is more appropriately because it is unknown what is happening before the event is triggered.

@futuremint
Copy link
Contributor

I didn't know the unit tests were previous broken. You don't need to open a PR, @swilliamset can look into those. I just wanted to double check they weren't from your code changes is all.

@swilliamset
Copy link
Contributor

swilliamset commented Apr 19, 2017

unit tests are failing on repeater tests the same as #1959. i'm looking into it.

once i have unit tests resolved and merged in the PR with a fix you can rebase this PR.

After programmatically setting the value of the spinbox, the previous
value would be retained in the lastValue property of the control,
causing the "changed" event not to get triggered if the user were to
enter the previous value again. To avoid this, the current setValue
method was converted into a private method with an additional parameter
to set the last value, and the public method will wrap this and pass
that parameter, while internal uses of the method will use the private
method to avoid other side effects.

Fixes #1950
@vargasd
Copy link
Contributor Author

vargasd commented Apr 25, 2017

Hey @swilliamset, I have rebased and tests are now passing.

@scotthetrick
Copy link

@swilliamset Now that Sam has rebased and the tests are passing, is there anything else you need to complete the review?

@swilliamset
Copy link
Contributor

i'll take a look at this on Monday.

@scotthetrick
Copy link

@swilliamset any update on this review? Thanks.

@cmcculloh-kr cmcculloh-kr added this to the 3.15.13 milestone May 3, 2017
@swilliamset
Copy link
Contributor

My apologies for the delay. This is priority 0 today.

$spinbox.spinbox('setValue', '2');

$spinbox.on('changed.fu.spinbox', function () {
assert.ok(true, 'spinbox triggers changed after input' );
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine for now but for future reference when using an event listener an async test is more appropriately because it is unknown what is happening before the event is triggered.

@swilliamset swilliamset merged commit d025932 into ExactTarget:master May 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants