fix(techdocs): Code block Copy To Clipboard button layout with latest mkdocs-material

Signed-off-by: Gabriel Dugny <gabriel.dugny@believe.com>
This commit is contained in:
Gabriel Dugny
2026-01-07 14:22:19 +01:00
parent 9e7751b257
commit 94ff7abe78
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-techdocs': patch
---
Code block "Copy to clipboard" button was not positioned correctly for docs built with `mkdocs-material>=9.7`
@@ -67,7 +67,12 @@ const CopyToClipboardButton = ({ text }: CopyToClipboardButtonProps) => {
leaveDelay={1000}
>
<IconButton
style={{ position: 'absolute' }}
style={{
position: 'absolute',
// top & right was removed from upstream .md-clipboard in mkdocs-material 9.7.0
top: '0.5rem',
right: '0.5rem',
}}
className="md-clipboard md-icon"
onClick={handleClick}
aria-label="Copy to clipboard"
@@ -81,6 +86,8 @@ const CopyToClipboardButton = ({ text }: CopyToClipboardButtonProps) => {
/**
* Recreates copy-to-clipboard functionality attached to <code> snippets that
* is native to mkdocs-material theme.
*
* Unlike native mkdocs-material theme, this is always enabled and does not respect the mkdocs's config `theme.features` `content.code.copy` setting.
*/
export const copyToClipboard = (theme: Theme): Transformer => {
return dom => {