Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-08-10 15:38:07 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-08-10 15:38:07 -0400
commitf6c58621687e5ec8ffb0e483b84187761cb3e5f2 (patch)
tree35b8fe418f0f8f45907bd971a7896d6bf99bf14f
parent2e88e9795c7b510d77748c4413b133b8e1c8ca01 (diff)
parente24038503bf4af01a668fa9a1ed5b9b51c3a4da5 (diff)
downloadliza-3.9.4.tar.gz
liza-3.9.4.tar.bz2
liza-3.9.4.zip
[bugfix] DataApiMediator: Wait for stack to clear before updating optionsv3.9.4
-rw-r--r--src/client/dapi/DataApiMediator.js30
-rw-r--r--test/client/dapi/DataApiMediatorTest.js2
2 files changed, 19 insertions, 13 deletions
diff --git a/src/client/dapi/DataApiMediator.js b/src/client/dapi/DataApiMediator.js
index 89b600b..58f9fae 100644
--- a/src/client/dapi/DataApiMediator.js
+++ b/src/client/dapi/DataApiMediator.js
@@ -166,22 +166,26 @@ module.exports = Class( 'DataApiMediator',
: this._getDefaultValue( val_label )
);
- indexes.forEach( ( _, i ) =>
- group.setOptions( name, i, val_label, existing[ i ] )
- );
-
-
- const update = this._populateWithMap(
- dapi_manager, name, indexes, quote
- );
-
- update[ name ] = field_update;
-
// allow the stack to clear before setting data to allow any
// existing bucket processing to complete before hooks are kicked
// off yet again (which, in practice, could otherwise result in
- // infinite recursion depending on what the hooks are doing)
- setTimeout( () => quote.setData( update ) );
+ // infinite recursion depending on what the hooks are doing), and to
+ // allow the UI to update with any new elements we might be about to
+ // populate
+ setTimeout( () =>
+ {
+ indexes.forEach( ( _, i ) =>
+ group.setOptions( name, i, val_label, existing[ i ] )
+ );
+
+ const update = this._populateWithMap(
+ dapi_manager, name, indexes, quote
+ );
+
+ update[ name ] = field_update;
+
+ quote.setData( update );
+ } );
},
diff --git a/test/client/dapi/DataApiMediatorTest.js b/test/client/dapi/DataApiMediatorTest.js
index 62e12b1..6bf2017 100644
--- a/test/client/dapi/DataApiMediatorTest.js
+++ b/test/client/dapi/DataApiMediatorTest.js
@@ -368,6 +368,8 @@ describe( "DataApiMediator", () =>
[name]: {
setOptions( given_name, given_index, given_data, given_cur )
{
+ expect( stack_cleared ).to.be.true;
+
// index is implicitly tested by the given_cur line
expect( given_name ).to.equal( name );
expect( given_data ).to.deep.equal( val_label );