From 0cbc2506892c47ad25fc9e19dcc295ee199c5b30 Mon Sep 17 00:00:00 2001 From: Navaneeth Pk Date: Fri, 10 Sep 2021 12:50:20 +0530 Subject: [PATCH] Fix for onSelect event of dropdowns (#722) * onSelect event for dropdown * onSelect should be fired after state change --- frontend/src/Editor/Components/DropDown.jsx | 5 +++-- frontend/src/_helpers/appUtils.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/Editor/Components/DropDown.jsx b/frontend/src/Editor/Components/DropDown.jsx index 08ff8d20a8..c67230c772 100644 --- a/frontend/src/Editor/Components/DropDown.jsx +++ b/frontend/src/Editor/Components/DropDown.jsx @@ -9,7 +9,8 @@ export const DropDown = function DropDown({ component, onComponentClick, currentState, - onComponentOptionChanged + onComponentOptionChanged, + onEvent }) { console.log('currentState', currentState); @@ -78,7 +79,7 @@ export const DropDown = function DropDown({ }, [newValue]); useEffect(() => { - onComponentOptionChanged(component, 'value', currentValue); + onComponentOptionChanged(component, 'value', currentValue).then(() => onEvent('onSelect', { component }) ); }, [currentValue]); return ( diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index 433590f790..698760a158 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -242,7 +242,7 @@ export async function onEvent(_ref, eventName, options, mode = 'edit') { }); } - if (['onDetect', 'onCheck', 'onUnCheck', 'onBoundsChange', 'onCreateMarker', 'onMarkerClick', 'onPageChanged', 'onSearch', 'onChange', 'onSelectionChange'].includes(eventName)) { + if (['onDetect', 'onCheck', 'onUnCheck', 'onBoundsChange', 'onCreateMarker', 'onMarkerClick', 'onPageChanged', 'onSearch', 'onChange', 'onSelectionChange', 'onSelect'].includes(eventName)) { const { component } = options; executeActionsForEventId(_ref, eventName, component, mode); }