Skip to content

Commit

Permalink
fix: update links in head and *isLoaded to true (openedx#534)
Browse files Browse the repository at this point in the history
Co-authored-by: monteri <lansevermore>
  • Loading branch information
monteri authored and dcoa committed Apr 4, 2024
1 parent b80b06d commit e2bbac5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/react/hooks/paragon/useParagonThemeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const useParagonThemeCore = ({
setIsBrandThemeCoreLoaded(true);
return;
}
const getParagonThemeCoreLink = () => document.head.querySelector('link[data-paragon-theme-core="true"');
const getParagonThemeCoreLink = () => document.head.querySelector('link[data-paragon-theme-core="true"]');
const existingCoreThemeLink = document.head.querySelector(`link[href='${themeCore.urls.default}']`);
const brandCoreLink = document.head.querySelector(`link[href='${themeCore.urls.brandOverride}']`);
if (!existingCoreThemeLink) {
const getExistingCoreThemeLinks = (isBrandOverride) => {
const coreThemeLinkSelector = `link[data-${isBrandOverride ? 'brand' : 'paragon'}-theme-core="true"]`;
Expand Down Expand Up @@ -126,6 +127,15 @@ const useParagonThemeCore = ({
} else {
setIsBrandThemeCoreLoaded(true);
}
} else {
existingCoreThemeLink.rel = 'stylesheet';
existingCoreThemeLink.removeAttribute('as');
if (brandCoreLink) {
brandCoreLink.rel = 'stylesheet';
brandCoreLink.removeAttribute('as');
}
setIsParagonThemeCoreLoaded(true);
setIsBrandThemeCoreLoaded(true);
}
}, [themeCore?.urls, onLoad]);
};
Expand Down
8 changes: 7 additions & 1 deletion src/react/hooks/paragon/useParagonThemeVariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ const useParagonThemeVariants = ({
} else {
const updatedStylesheetRel = generateStylesheetRelAttr(themeVariant);
existingThemeVariantLink.rel = updatedStylesheetRel;
existingThemeVariantBrandLink.rel = updatedStylesheetRel;
existingThemeVariantLink.removeAttribute('as');
if (existingThemeVariantBrandLink) {
existingThemeVariantBrandLink.rel = updatedStylesheetRel;
existingThemeVariantBrandLink.removeAttribute('as');
}
setIsParagonThemeVariantLoaded(true);
setIsBrandThemeVariantLoaded(true);
}
});
}, [themeVariants, currentThemeVariant, onLoad]);
Expand Down

0 comments on commit e2bbac5

Please sign in to comment.