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 Dec 30, 2023
1 parent 0f383e9 commit 2497697
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 2497697

Please sign in to comment.