From 175bde36d65ea746c9d1dc686b1609f1a7dba577 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 25 Feb 2022 08:25:56 +0000 Subject: [PATCH] Ensure data binding generation doesn't crash if no asset is selected --- packages/builder/src/builderStore/dataBinding.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index b4d1c0d1c1..60cce2b1fd 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -32,14 +32,14 @@ export const getBindableProperties = (asset, componentId) => { const urlBindings = getUrlBindings(asset) const deviceBindings = getDeviceBindings() const stateBindings = getStateBindings() - const rowBindings = getRowBindings(asset) + const selectedRowsBindings = getSelectedRowsBindings(asset) return [ ...contextBindings, ...urlBindings, ...stateBindings, ...userBindings, ...deviceBindings, - ...rowBindings, + ...selectedRowsBindings, ] } @@ -318,13 +318,13 @@ const getDeviceBindings = () => { } /** - * Gets all row bindings that are globally available. + * Gets all selected rows bindings for tables in the current asset. */ -const getRowBindings = asset => { +const getSelectedRowsBindings = asset => { let bindings = [] if (get(store).clientFeatures?.rowSelection) { // Add bindings for table components - let tables = findAllMatchingComponents(asset.props, component => + let tables = findAllMatchingComponents(asset?.props, component => component._component.endsWith("table") ) const safeState = makePropSafe("rowSelection") @@ -337,7 +337,7 @@ const getRowBindings = asset => { ) // Add bindings for table blocks - let tableBlocks = findAllMatchingComponents(asset.props, component => + let tableBlocks = findAllMatchingComponents(asset?.props, component => component._component.endsWith("tableblock") ) bindings = bindings.concat(