Skip to content

Commit

Permalink
fix: clean up for autoresize
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Aug 15, 2023
1 parent 1191a7c commit 6c705ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
15 changes: 13 additions & 2 deletions adapter/src/components/AppWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { ErrorBoundary } from './ErrorBoundary.js'
import { LoadingMask } from './LoadingMask.js'
import { styles } from './styles/AppWrapper.style.js'

const AppWrapper = ({ children, plugin, onPluginError, clearPluginError }) => {
const AppWrapper = ({
children,
plugin,
autoResizePlugin,
onPluginError,
clearPluginError,
}) => {
const { loading: localeLoading } = useCurrentUserLocale()
const { loading: latestUserLoading } = useVerifyLatestUser()

Expand All @@ -20,7 +26,11 @@ const AppWrapper = ({ children, plugin, onPluginError, clearPluginError }) => {
return (
<div className="app-shell-adapter">
<style jsx>{styles}</style>
<div className="app-shell-app">
<div
className={
autoResizePlugin ? 'app-shell-plugin' : 'app-shell-app'
}
>
<ErrorBoundary
plugin={true}
onPluginError={onPluginError}
Expand Down Expand Up @@ -52,6 +62,7 @@ const AppWrapper = ({ children, plugin, onPluginError, clearPluginError }) => {
}

AppWrapper.propTypes = {
autoResizePlugin: PropTypes.bool,
children: PropTypes.node,
clearPluginError: PropTypes.func,
plugin: PropTypes.bool,
Expand Down
5 changes: 5 additions & 0 deletions adapter/src/components/styles/AppWrapper.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ export const styles = css`
overflow: auto;
height: 100%;
}
div.app-shell-plugin {
flex: 1 1 auto;
overflow: hidden;
height: 100%;
}
`
3 changes: 3 additions & 0 deletions adapter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ServerVersionProvider } from './components/ServerVersionProvider.js'
const AppAdapter = ({
appName,
appVersion,
autoResizePlugin,
url,
apiVersion,
pwaEnabled,
Expand Down Expand Up @@ -39,6 +40,7 @@ const AppAdapter = ({
>
<AppWrapper
plugin={plugin}
autoResizePlugin={autoResizePlugin}
onPluginError={onPluginError}
clearPluginError={clearPluginError}
>
Expand All @@ -54,6 +56,7 @@ AppAdapter.propTypes = {
appName: PropTypes.string.isRequired,
appVersion: PropTypes.string.isRequired,
apiVersion: PropTypes.number,
autoResizePlugin: PropTypes.bool,
children: PropTypes.element,
clearPluginError: PropTypes.func,
parentAlertsAdd: PropTypes.func,
Expand Down
9 changes: 1 addition & 8 deletions shell/src/PluginLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ const PluginInner = ({
(resizePluginHeight || resizePluginWidth)
) {
const resizeObserver = new ResizeObserver(() => {
console.log(
'height,scrollHeight,offsetWidth,scrollWidth',
divRef.current.offsetHeight,
divRef.current.scrollHeight,
divRef.current.offsetWidth,
divRef.current.scrollWidth
)
// the additional pixels currently account for possible horizontal scroll bar
if (resizePluginHeight) {
resizePluginHeight(divRef.current.offsetHeight + 20)
}
Expand Down Expand Up @@ -198,6 +190,7 @@ export const PluginLoader = ({ config, requiredProps, D2App }) => {
showAlertsInPlugin={showAlertsInPlugin}
onPluginError={onPluginError}
clearPluginError={clearPluginError}
autoResizePlugin={resizePluginHeight || resizePluginWidth}
{...config}
>
<React.Suspense
Expand Down

0 comments on commit 6c705ec

Please sign in to comment.