BUG-6029 : Property pane for iFrame widget does not appear on clicking on widget (#6260)

-- Add a overlaid div for iframe
This commit is contained in:
Paul Li 2021-08-09 05:51:33 -04:00 committed by GitHub
parent b7fb9bd58b
commit a92b7595db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -3,6 +3,9 @@ import styled from "styled-components";
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
import { hexToRgba } from "components/ads/common";
import { AppState } from "reducers";
import { useSelector } from "store";
import { RenderMode, RenderModes } from "constants/WidgetConstants";
interface IframeContainerProps {
borderColor?: string;
@ -11,6 +14,7 @@ interface IframeContainerProps {
}
export const IframeContainer = styled.div<IframeContainerProps>`
position: relative;
display: flex;
align-items: center;
justify-content: center;
@ -34,7 +38,16 @@ export const IframeContainer = styled.div<IframeContainerProps>`
}
`;
const OverlayDiv = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
`;
export interface IframeComponentProps extends ComponentProps {
renderMode: RenderMode;
source: string;
title?: string;
onURLChanged: (url: string) => void;
@ -51,8 +64,10 @@ function IframeComponent(props: IframeComponentProps) {
borderWidth,
onMessageReceived,
onURLChanged,
renderMode,
source,
title,
widgetId,
} = props;
const [message, setMessage] = useState("");
@ -74,12 +89,24 @@ function IframeComponent(props: IframeComponentProps) {
}
}, [source]);
const isPropertyPaneVisible = useSelector(
(state: AppState) => state.ui.propertyPane.isVisible,
);
const selectedWidgetId = useSelector(
(state: AppState) => state.ui.propertyPane.widgetId,
);
return (
<IframeContainer
borderColor={borderColor}
borderOpacity={borderOpacity}
borderWidth={borderWidth}
>
{renderMode === RenderModes.CANVAS &&
!(isPropertyPaneVisible && widgetId === selectedWidgetId) && (
<OverlayDiv />
)}
{message ? message : <iframe src={source} title={title} />}
</IframeContainer>
);

View File

@ -141,6 +141,7 @@ class IframeWidget extends BaseWidget<IframeWidgetProps, WidgetState> {
borderColor,
borderOpacity,
borderWidth,
renderMode,
source,
title,
widgetId,
@ -153,6 +154,7 @@ class IframeWidget extends BaseWidget<IframeWidgetProps, WidgetState> {
borderWidth={borderWidth}
onMessageReceived={this.messageReceivedHandler}
onURLChanged={this.urlChangedHandler}
renderMode={renderMode}
source={source}
title={title}
widgetId={widgetId}