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

Bug: Sidebar activation body is sometimes missing #8965

Closed
mnholtz opened this issue Aug 2, 2024 · 2 comments · Fixed by #9072
Closed

Bug: Sidebar activation body is sometimes missing #8965

mnholtz opened this issue Aug 2, 2024 · 2 comments · Fixed by #9072
Assignees
Labels
bug Something isn't working

Comments

@mnholtz
Copy link
Collaborator

mnholtz commented Aug 2, 2024

Describe the bug

The body of the sidebar mod activation panel is sometimes missing, despite the elements being present in the DOM:
image.png
image.png

To Reproduce

Unfortunately, there is not a reliable way to reproduce. But it happens after:

  1. Visiting the Marketplace www.pixiebrix.com/marketplace
  2. Going to a Marketplace listing detail
  3. Clicking "Activate" for that mod with the PixieBrix Extension installed

Actual behavior

Sidebar shows only the CTA buttons, and no sidebar activation panel body, despite the body being present in the DOM.

Expected behavior

Sidebar panel is fully-populated with sidebar activation copy/mod configuration options.

Additional context

@mnholtz mnholtz added the bug Something isn't working label Aug 2, 2024
@twschiller
Copy link
Contributor

twschiller commented Aug 20, 2024

The mod in question is a 1-click wonder (doesn't have any activation options), so it shouldn't be showing the activation form (Cancel/OK) https://www.pixiebrix.com/marketplace/31013451-a9ed-4d1f-9cc0-f869ceb767be/

What might be happening is there's an error fetching some data (the marketplace listing?) causing some of the
content not to be rendered which is then also interacting with the scrollable-area class

Code Reference:

const ActivateModPanel: React.FC<{ mod: ModActivationConfig }> = ({ mod }) => {

@grahamlangford grahamlangford self-assigned this Aug 28, 2024
@grahamlangford
Copy link
Collaborator

grahamlangford commented Aug 28, 2024

It's not an error, and this component isn't a 1-click wonder. The css file is being disabled by IsolatedComponent:

When the bug is replicated:

image

When the sidebar renders as expected:

image

Note the difference for /css/ActivatePanels.css

Looks to be a race condition that is only reproducible if there is another panel open

See

async function discardStylesheetsWhilePending(
lazyFactory: LazyFactory<unknown>,
) {
const baseUrl = chrome.runtime.getURL("");
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node instanceof HTMLLinkElement && node.href.startsWith(baseUrl)) {
// Disable stylesheet without removing it. Webpack still awaits its loading.
node.media = "not all";
node.dataset.pixiebrix = "Disabled by IsolatedComponent";
}
}
}
});
observer.observe(document.head, {
childList: true,
});
// Call and discard. React.lazy() will call it again and use the result or the error.
// This is fine because import() does not re-fetch/re-run the module.
try {
// The function must be first called *after* the observer is set up.
await lazyFactory();
} catch {
// React.lazy() will take care of it
} finally {
observer.disconnect();
}
}

grahamlangford added a commit that referenced this issue Aug 28, 2024
* fix sidebar activation body sometimes missing

* use allowlist

* explain cssFileAllowList wiht comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants