Skip to content

Commit f55fdcf

Browse files
committed
fix: updated offset feedback button below code block header
1 parent 6584b15 commit f55fdcf

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/components/DocFeedbackProvider.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,12 @@ function BlockButton({
401401
if (!portalContainer) {
402402
portalContainer = document.createElement('div')
403403
portalContainer.setAttribute('data-button-portal', blockId)
404-
portalContainer.className =
405-
'absolute top-0 right-0 -translate-y-full z-[100]'
404+
// Nudge down when following a <code> block so the button doesn't overlap with the code's top bar
405+
const precedesCodeBlock = block.lastElementChild?.tagName === 'CODE'
406+
portalContainer.className = twMerge(
407+
'absolute right-0 -translate-y-full z-[100]',
408+
precedesCodeBlock ? 'top-6' : 'top-0',
409+
)
406410
portalContainer.style.position = 'absolute'
407411

408412
// Make the block relatively positioned if not already

0 commit comments

Comments
 (0)