Skip to content

Commit

Permalink
fix: allow resize w/ fixed dimensions without re-rendering plugin con…
Browse files Browse the repository at this point in the history
…tent
  • Loading branch information
edoardo committed Aug 29, 2024
1 parent 6788af6 commit c5d6bc2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions services/plugin/src/Plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const getPluginEntryPoint = ({
export const Plugin = ({
pluginSource,
pluginShortName,
height,
width,
...propsToPassNonMemoized
}: {
pluginSource?: string
Expand All @@ -42,7 +44,7 @@ export const Plugin = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
[propsToPassNonMemoizedJSON]
)
const { height, width } = propsToPass
const { hasFixedDimensions } = propsToPass

const { add: alertsAdd } = useContext(AlertsManagerContext)

Expand All @@ -60,8 +62,8 @@ export const Plugin = ({
useState<boolean>(false)

const [inErrorState, setInErrorState] = useState<boolean>(false)
const [pluginHeight, setPluginHeight] = useState<number>(150)
const [pluginWidth, setPluginWidth] = useState<number>(500)
const [pluginHeight, setPluginHeight] = useState<number>(height || 150)
const [pluginWidth, setPluginWidth] = useState<number>(width || 500)

useEffect(() => {
if (height) {
Expand Down Expand Up @@ -100,8 +102,8 @@ export const Plugin = ({
const iframeProps = {
...memoizedPropsToPass,
alertsAdd,
setPluginHeight,
setPluginWidth,
setPluginHeight: hasFixedDimensions ? null : setPluginHeight,
setPluginWidth: hasFixedDimensions ? null : setPluginWidth,
setInErrorState,
setCommunicationReceived,
}
Expand Down

0 comments on commit c5d6bc2

Please sign in to comment.