fixes: Component inspector go blank after switching to different pages after dropping components (#7637)

This commit is contained in:
Arpit 2023-10-06 16:35:47 +05:30 committed by GitHub
parent afbd4a24d5
commit b3625d6cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -531,16 +531,6 @@ const EditorComponent = (props) => {
}
};
const onAreaSelectionEnd = (e) => {
setSelectionInProgress(false);
e.selected.forEach((el, index) => {
const id = el.getAttribute('widgetid');
const component = appDefinition?.pages[currentPageId].components[id].component;
const isMultiSelect = e.inputEvent.shiftKey || (!e.isClick && index != 0);
setSelectedComponent(id, component, isMultiSelect);
});
};
const setSelectedComponent = (id, component, multiSelect = false) => {
if (selectedComponents.length === 0 || !multiSelect) {
switchSidebarTab(1);
@ -558,6 +548,16 @@ const EditorComponent = (props) => {
}
};
const onAreaSelectionEnd = (e) => {
setSelectionInProgress(false);
e.selected.forEach((el, index) => {
const id = el.getAttribute('widgetid');
const component = appDefinition?.pages[currentPageId].components[id].component;
const isMultiSelect = e.inputEvent.shiftKey || (!e.isClick && index != 0);
setSelectedComponent(id, component, isMultiSelect);
});
};
const onVersionRelease = (versionId) => {
useAppVersionStore.getState().actions.updateReleasedVersionId(versionId);
@ -1206,6 +1206,11 @@ const EditorComponent = (props) => {
};
setCurrentPageId(newPageId);
setHoveredComponent(null);
updateEditorState({
currentSidebarTab: 2,
selectedComponents: [],
});
appDefinitionChanged(copyOfAppDefinition, {
pageDefinitionChanged: true,
@ -1748,24 +1753,20 @@ const EditorComponent = (props) => {
{currentSidebarTab === 1 && (
<div className="pages-container">
{selectedComponents.length === 1 &&
!isEmpty(appDefinition?.pages[currentPageId]?.components) &&
!isEmpty(appDefinition?.pages[currentPageId]?.components[selectedComponents[0].id]) ? (
<Inspector
moveComponents={moveComponents}
componentDefinitionChanged={componentDefinitionChanged}
removeComponent={removeComponent}
selectedComponentId={selectedComponents[0].id}
allComponents={appDefinition?.pages[currentPageId]?.components}
key={selectedComponents[0].id}
switchSidebarTab={switchSidebarTab}
darkMode={props.darkMode}
pages={getPagesWithIds()}
></Inspector>
) : (
<center className="mt-5 p-2">
{props.t('editor.inspectComponent', 'Please select a component to inspect')}
</center>
)}
!isEmpty(appDefinition?.pages[currentPageId]?.components) &&
!isEmpty(appDefinition?.pages[currentPageId]?.components[selectedComponents[0].id]) && (
<Inspector
moveComponents={moveComponents}
componentDefinitionChanged={componentDefinitionChanged}
removeComponent={removeComponent}
selectedComponentId={selectedComponents[0].id}
allComponents={appDefinition?.pages[currentPageId]?.components}
key={selectedComponents[0].id}
switchSidebarTab={switchSidebarTab}
darkMode={props.darkMode}
pages={getPagesWithIds()}
></Inspector>
)}
</div>
)}