-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Themes: Hide "Theme Showcase" broken action (#36986)
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/packages/jetpack-mu-wpcom/changelog/remove-theme-showcase-action-from-theme-details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fixed | ||
|
||
Themes: Fixed an issue that was showing a broken Theme Showcase action in the active theme details |
32 changes: 32 additions & 0 deletions
32
projects/packages/jetpack-mu-wpcom/src/features/wpcom-themes/js/theme-actions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const wpcomThemesRemoveWpcomActions = () => { | ||
const themeOverlay = document.querySelector( '.theme-overlay' ); | ||
if ( ! themeOverlay ) { | ||
return; | ||
} | ||
|
||
const observer = new MutationObserver( mutations => { | ||
for ( const mutation of mutations ) { | ||
for ( const node of mutation.addedNodes ) { | ||
// If this is not an overlay for the active theme, bail and check the next node. | ||
if ( | ||
! node.classList.contains( 'theme-overlay' ) || | ||
! node.classList.contains( 'active' ) | ||
) { | ||
continue; | ||
} | ||
|
||
const themeActions = node.querySelector( '.theme-actions .active-theme' ); | ||
for ( const action of themeActions?.children ?? [] ) { | ||
if ( action.getAttribute( 'href' )?.includes( 'https://wordpress.com' ) ) { | ||
themeActions.removeChild( action ); | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
} ); | ||
|
||
observer.observe( themeOverlay, { childList: true } ); | ||
}; | ||
|
||
document.addEventListener( 'DOMContentLoaded', wpcomThemesRemoveWpcomActions ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters