Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apps that dynamically calculate height are broken, during app.activated core event document.body.clientHeight/scrollHeight is 0 #164

Open
1951FDG opened this issue Apr 21, 2022 · 0 comments

Comments

@1951FDG
Copy link

1951FDG commented Apr 21, 2022

Problem

Apps dynamically calculating their height during app.activated core event, are not able to resize correctly due to 0 height being returned. I believe this has been an issue since about 1 month ago.

This issue can be reproduced while switching tabs back and forth in Zendesk.

Whenever this happens a workaround is to refresh the apps, which will fire app.registered core event again.

Some of the apps affected are:

image

Example code to debug

/**
 * Event Listener that fires when the app becomes active. Resizes the app's iframe dimensions.
 */
client.on('app.activated', (event) => {
  client.invoke('resize', { height: `${document.body.clientHeight}px` }).then((data) => {
    console.error(`body client height: ${document.body.clientHeight}`);
    console.error(`body scroll height: ${document.body.scrollHeight}`);
    console.error(`html client height: ${document.documentElement.clientHeight}`);
    console.error(`html scroll height: ${document.documentElement.scrollHeight}`);
    console.error(`${getComputedStyle(document.documentElement).getPropertyValue('height')}`);
  });
});

Environment

Google Chrome - Version 100.0.4896.127

Additional info:

core_api/#resize

Note: Ensure that you always invoke a resize whenever the app.activated core event is fired if your app is dynamically calculating it's height. This is considered as a best practice to prevent a resizing issue where the body scrollHeight of the iframe would return a value of 0 whenever an agent switches to another ticket tab, while your app in the original tab was still in the process of being loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant