Close property pane when clicking outside the property pane. Select widget when toggling open the property pane.

This commit is contained in:
Abhinav Jha 2020-05-13 19:58:27 +05:30
parent 9f2267ed68
commit 591a5d3eff
2 changed files with 10 additions and 1 deletions

View File

@ -139,6 +139,9 @@ const DraggableComponent = (props: DraggableComponentProps) => {
selectWidget &&
selectedWidget !== props.widgetId &&
selectWidget(props.widgetId);
selectedWidget !== props.widgetId &&
showPropertyPane &&
showPropertyPane();
}
e.stopPropagation();
};

View File

@ -8,7 +8,10 @@ import { theme } from "constants/DefaultTheme";
import { Colors } from "constants/Colors";
import { PropertyPaneReduxState } from "reducers/uiReducers/propertyPaneReducer";
import { Tooltip } from "@blueprintjs/core";
import { useShowPropertyPane } from "utils/hooks/dragResizeHooks";
import {
useShowPropertyPane,
useWidgetSelection,
} from "utils/hooks/dragResizeHooks";
import AnalyticsUtil from "utils/AnalyticsUtil";
import { WidgetOperations } from "widgets/BaseWidget";
import { WidgetType } from "constants/WidgetConstants";
@ -66,6 +69,8 @@ type WidgetNameComponentProps = {
export const WidgetNameComponent = (props: WidgetNameComponentProps) => {
const { updateWidget } = useContext(EditorContext);
const showPropertyPane = useShowPropertyPane();
// Dispatch hook handy to set a widget as focused/selected
const { selectWidget } = useWidgetSelection();
const propertyPaneState: PropertyPaneReduxState = useSelector(
(state: AppState) => state.ui.propertyPane,
);
@ -122,6 +127,7 @@ export const WidgetNameComponent = (props: WidgetNameComponentProps) => {
widgetId: props.widgetId,
});
showPropertyPane && showPropertyPane(props.widgetId, undefined, true);
selectWidget && selectWidget(props.widgetId);
} else {
AnalyticsUtil.logEvent("PROPERTY_PANE_CLOSE_CLICK", {
widgetType: props.type,