Skip to content

[$250] Chat - Copy to clipboard icon is appearing over the code block text #94868

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.4.22-2
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/62515464/folder/13176723/41237034/1526206654?sort=%2Bidentifier
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Web
App Component: Other

Action Performed:

  1. Navigate to https://staging.new.expensify.com
  2. Navigate to any chat
  3. Send a message with code block format eg:
test
  1. Hover the mouse over the message sent

Expected Result:

Copy to clipboard icon should not appear over the code block format message

Actual Result:

A copy to clipboard icon is appearing over the code block message.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

To be added by Applause Leads

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7194452

Upwork Automation - Do Not Edit

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 29, 2026
  2. applause-bot commented on Jun 29, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/1a6fa36125cff106d7cf99e069ec097301b4fce58628a01f4b8c2eb5361a9fef

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 29, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 29, 2026
  5. yusufdeveloper2903 commented on Jun 29, 2026

    @yusufdeveloper2903
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-29 15:40:07 UTC.

    Proposal

    What is the root cause of that problem?

    This is a regression from the new "copy code block on hover" feature, merged in PR #94337 (d20274a295d, June 23) — which is why it reproduces in staging but not production.

    When a code block is hovered, PreRenderer renders a CopyTextToClipboard button that is absolutely positioned over the top‑right corner of the block:

    {isHovered && !!codeText && (
    <View style={isMultilineCodeBlock ? styles.codeBlockCopyButtonWrapperMultiline : styles.codeBlockCopyButtonWrapper}>
    <CopyTextToClipboard
    urlToCopy={codeText}
    styles={styles.copyableTextFieldButton}
    iconStyles={styles.t0}
    shouldHaveActiveBackground
    shouldUseButtonBackground
    />
    </View>
    )}

    The wrapper styles place it at right: 4 (single‑line) / right: 8 (multi‑line), and the button itself is 28×28:

    App/src/styles/index.ts

    Lines 6129 to 6147 in 05d32d5

    copyableTextFieldButton: {
    width: 28,
    height: 28,
    borderRadius: variables.buttonBorderRadius,
    justifyContent: 'center',
    alignItems: 'center',
    },
    // Single-line code blocks keep the copy button tight to the corner.
    codeBlockCopyButtonWrapper: {
    position: 'absolute',
    top: 4,
    right: 4,
    },
    // Multi-line code blocks get extra breathing room around the copy button.
    codeBlockCopyButtonWrapperMultiline: {
    position: 'absolute',
    top: 8,
    right: 8,
    },

    The problem is the geometry of the block underneath it. A <pre> is content‑sized — it uses whiteSpace: 'pre' with no width, and only paddingHorizontal: 12:

    App/src/styles/index.ts

    Lines 210 to 218 in 05d32d5

    pre: {
    ...baseCodeTagStyles(theme),
    paddingVertical: 8,
    paddingHorizontal: 12,
    fontSize: undefined,
    ...FontUtils.fontFamily.platform.MONOSPACE,
    marginTop: 0,
    marginBottom: 0,
    },

    So the bordered box shrinks to fit its text, and no horizontal gutter is reserved for the button. The 28px button (which carries its own solid background via shouldUseButtonBackground) is pinned 4px from the block's right edge, i.e. on top of the last characters of the code. For a short single‑line block like the repro's test, the block is only ~24px of padding plus the text width, so the button lands squarely over the text and hides it.

    So: content‑sized <pre> (no reserved right gutter) → an absolutely‑positioned 28px copy button pinned to the block's right edge → the button's background covers the code text on hover, worst on short single‑line blocks.

    What changes do you think we should make in order to solve the problem?

    Reserve a right‑hand gutter inside the code block equal to the copy‑button footprint, so the text never renders underneath the button. Because the gutter is permanent (not hover‑gated), there is also no layout shift when the button fades in — which is exactly why the button was made absolute in the first place.

    The block style is already passed straight into the <pre> renderer (the task‑title branch already does this via style={styles.taskTitleMenuItem}), so the smallest change is to pass a style that adds the gutter to the normal render path:

    - <TDefaultRenderer {...defaultRendererProps} />
    + <TDefaultRenderer
    +     {...defaultRendererProps}
    +     style={styles.codeBlockWithCopyButton}
    + />

    with a new shared style sized to clear the button (button 28px + its right inset + a small gap, on top of the existing 12px padding):

    + codeBlockWithCopyButton: {
    +     paddingRight: 40,
    + },

    This pushes the code text left so the absolutely‑positioned button sits over empty padding instead of over the text, and it fixes both the single‑line and multi‑line variants at once. The exact paddingRight value (and gating it to web/desktop, since Hoverable never fires the button on native) can be finalized in the PR.

    What alternative solutions did you explore? (Optional)

    Move the button out of the block entirely — render it in a flexDirection: 'row' next to the <pre> instead of absolutely over it. This guarantees no overlap, but reintroduces a layout shift each time the button mounts/unmounts on hover, and complicates wrapping on narrow screens. Reserving an internal gutter is fewer lines, keeps the existing absolute‑positioning (no hover jump), and fixes the root cause directly.

  6. KJ21-ENG commented on Jun 29, 2026

    @KJ21-ENG
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-29 16:50:00 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On web, hovering a chat message that contains a triple-backtick code block shows the copy-to-clipboard button directly over the rendered code text. This is most visible for a short single-line block like test, where the 28px copy button can cover most or all of the code.

    What is the root cause of that problem?

    This is a regression from the recently added code-block copy affordance in PR #94337. PreRenderer extracts the raw code text with getCodeBlockText(), detects whether the block is single-line or multi-line, and renders CopyTextToClipboard as an absolutely positioned hover-only button:

    const codeText = HTMLEngineUtils.getCodeBlockText(defaultRendererProps.tnode);
    // Multi-line code blocks get extra breathing room around the copy button, while single-line blocks keep it tight to the corner.
    const isMultilineCodeBlock = codeText.trim().includes('\n');
    if (isChildOfTaskTitle) {
    return (
    <TDefaultRenderer
    {...defaultRendererProps}
    style={styles.taskTitleMenuItem}
    />
    );
    }
    return (
    <View style={isLast ? styles.mt2 : styles.mv2}>
    <Hoverable>
    {(isHovered) => (
    <View>
    <PressableWithoutFeedback
    sentryLabel={CONST.SENTRY_LABEL.HTML_RENDERER.PRE}
    onPress={onPressIn ?? (() => {})}
    onPressIn={onPressIn}
    onPressOut={onPressOut}
    onLongPress={(event) => {
    onShowContextMenu(() => {
    if (isDisabled || !shouldDisplayContextMenu) {
    return;
    }
    return showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, originalReportID);
    });
    }}
    shouldUseHapticsOnLongPress
    role={CONST.ROLE.PRESENTATION}
    accessibilityLabel={translate('accessibilityHints.preStyledText')}
    >
    <View>
    <Text style={{fontSize}}>
    <TDefaultRenderer {...defaultRendererProps} />
    </Text>
    </View>
    </PressableWithoutFeedback>
    {isHovered && !!codeText && (
    <View style={isMultilineCodeBlock ? styles.codeBlockCopyButtonWrapperMultiline : styles.codeBlockCopyButtonWrapper}>
    <CopyTextToClipboard
    urlToCopy={codeText}
    styles={styles.copyableTextFieldButton}
    iconStyles={styles.t0}
    shouldHaveActiveBackground
    shouldUseButtonBackground
    />
    </View>
    )}

    The copy button is placed at the top-right of the code block with right: 4 for single-line blocks and right: 8 for multi-line blocks, and the button itself is 28px wide:

    App/src/styles/index.ts

    Lines 6129 to 6147 in 50ff928

    copyableTextFieldButton: {
    width: 28,
    height: 28,
    borderRadius: variables.buttonBorderRadius,
    justifyContent: 'center',
    alignItems: 'center',
    },
    // Single-line code blocks keep the copy button tight to the corner.
    codeBlockCopyButtonWrapper: {
    position: 'absolute',
    top: 4,
    right: 4,
    },
    // Multi-line code blocks get extra breathing room around the copy button.
    codeBlockCopyButtonWrapperMultiline: {
    position: 'absolute',
    top: 8,
    right: 8,
    },

    The underlying <pre> block is content-sized and only has the normal code-block horizontal padding. It does not reserve any right-side gutter for the hover button:

    App/src/styles/index.ts

    Lines 210 to 218 in 50ff928

    pre: {
    ...baseCodeTagStyles(theme),
    paddingVertical: 8,
    paddingHorizontal: 12,
    fontSize: undefined,
    ...FontUtils.fontFamily.platform.MONOSPACE,
    marginTop: 0,
    marginBottom: 0,
    },

    So the button is painted over the code text instead of over empty space. For a short block such as test, the code block width is only the text plus its normal padding, which leaves no room for the button.

    This is separate from intentional copy surfaces such as CopyTextRenderer / the copy-text renderer. Those dedicated copy affordances should remain untouched and continue to work. The issue is specifically the geometry of the hover copy button rendered by the generic <pre> renderer for chat code blocks.

    What changes do you think we should make in order to solve the problem?

    Keep the code-block copy affordance from PR #94337, but reserve space for it inside the rendered <pre> block when the button is shown. In PreRenderer, preserve the existing CopyTextToClipboard hover behavior and pass an additional right-gutter style to TDefaultRenderer only when the code block has copyable text and is hovered.

    The important detail is that this style must be merged with the existing renderer style, not replace it. Replacing the style can strip the normal <pre> background, border, font, and padding, making the block look different from staging. Merging the existing style with a small right-gutter style keeps the regular code-block appearance while ensuring the copy button sits over reserved padding instead of over the text.

    Add a shared style such as codeBlockWithCopyButtonGutter with enough paddingRight to clear the 28px button plus its right inset and a small gap. Keep the existing single-line and multi-line button wrapper styles, keep getCodeBlockText() and its tests, and leave CopyTextRenderer / copy-text untouched.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • Render a single-line chat code block such as test, hover it, and verify the copy button is still shown but no longer overlaps the code text.
    • Verify the hovered code block keeps the normal <pre> background/border styling while adding only the reserved right-side gutter.
    • Render the same code block without hover and verify its normal non-hover appearance is unchanged.
    • Cover a multi-line code block to ensure the copy button also sits over reserved padding there.
    • Verify intentional copy surfaces that use CopyTextRenderer / copy-text still render their copy affordance.

    What alternative solutions did you explore? (Optional)

    Removing the copy button entirely would stop the overlap, but it would also remove the feature intentionally added in PR #94337 for all fenced chat code blocks. Moving the button outside the code block would avoid overlap too, but it changes the layout more significantly and can introduce hover-time layout shifts. Reserving an internal gutter is the smallest fix: the button remains available, the normal code-block UI remains intact, and the text no longer renders underneath the button.

  7. melvin-bot commented on Jun 29, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @huult (External)

  8. kitvasyl commented on Jun 29, 2026

    @kitvasyl

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Web, hovering a code-block message can position the copy-to-clipboard action over the code text.

    What is the root cause of that problem?

    In src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx, showContextMenu() assigns position.vertical to contextMenuDimensions.current.width when measuring an overflow-menu anchor. This stores a screen coordinate instead of the anchor width, so overflow positioning uses invalid dimensions and can place the menu over the code block.

    What changes do you think we should make in order to solve the problem?

    Update showContextMenu() to set contextMenuDimensions.current with width: position.width and height: position.height. Add a focused test covering overflow-menu anchor dimensions and placement for a short code-block message.

    What alternative solutions did you explore? (Optional)

    Special-casing code blocks or hiding the copy action would mask the symptom; correcting the invalid anchor width fixes the shared positioning logic.

  9. changed the title [-]Chat - Copy to clipboard icon is appearing over the code block text[/-] [+][$250] Chat - Copy to clipboard icon is appearing over the code block text[/+] on Jun 29, 2026
  10. melvin-bot commented on Jun 29, 2026

    @melvin-bot
  11. godzillaxbox19982014-lgtm commented on Jun 29, 2026

    @godzillaxbox19982014-lgtm

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Chat - Copy to clipboard icon is appearing over the code block text

    What is the root cause of that problem?

    I traced this to the path that handles test:

    What changes do you think we should make in order to solve the problem?

    • Update src/pages/inbox/report/actionContents/ChatMessageContent.tsx:76 to derive test from the report/transaction source that owns this flow before the value is consumed.
    • Carry the same normalized value through src/pages/inbox/report/SystemChatReportFooterMessage.tsx:21; that follows the safer family move to derive the recipient accountID once, then let both the eligibility selector and recipient selector use that same ID, so the write/optimistic/read paths agree instead of only changing the visible component.
    • Keep the change inside the Chat Report, Composer, Recipient Local Time surface and avoid changing chat composer rendering, Onyx selector churn.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    1. Add or update a regression in tests/unit/ComposerLocalTimeTest.tsx for the exact issue flow: Chat - Copy to clipboard icon is appearing over the code block text.
    2. Cover the counter-case near src/pages/inbox/report/actionContents/ChatMessageContent.tsx:76 so valid existing test behavior still works.
    3. Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.

    What alternative solutions did you explore? (Optional)

    • I would not add a broad new condition outside these referenced paths; the safer fix is to keep test consistent at the first read/write boundary shown above.
  12. aswin-s commented on Jun 29, 2026

    @aswin-s
    Contributor

    Note: This proposal is not a duplicate. It identifies a deeper root cause rather than the surface symptom.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Web (Chrome), when a user hovers a chat message containing a code block, the copy-to-clipboard icon appears overlapping the code block's text content. Expected behavior: the icon should be visible alongside the code block without covering any of the rendered code.

    What is the root cause of that problem?

    PR #94337 added an absolutely-positioned copy button overlay in src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx:85-86 using styles.codeBlockCopyButtonWrapper / codeBlockCopyButtonWrapperMultiline defined in src/styles/index.ts:6137-6147. Both wrapper styles use position: 'absolute' with top: 4/8 and right: 4/8, placed as a sibling of the <PressableWithoutFeedback> that renders <Text> containing the code (inside the same parent <View>). The code block itself was never given any top/right padding (or a reserved icon slot) to accommodate the 28×28 copyableTextFieldButton (src/styles/index.ts:6129-6135), so the absolute icon paints directly on top of the first line of code — exactly the symptom for the single-line \``test```` repro where the icon overlaps the word "test".

    What changes do you think we should make in order to solve the problem?

    1. src/styles/index.ts:6137-6147 — give the code block's inner container reserved space for the copy button (e.g., add paddingRight of ~36 and paddingTop of ~4/8 to the code text wrapper, or shift the existing pre/code padding styles to leave room at the top-right) so the absolute icon never overlaps text.
    2. src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx:78-94 — wrap the inner <Text>/<TDefaultRenderer> block in a <View> that applies the reserved padding above, ensuring single-line code blocks (height ≈ one line) push the rendered text left of the icon rather than under it.
    3. Alternatively, keep the icon hidden until hover AND render it outside the code block bounds (e.g., absolutely positioned with top: -X or in a row layout next to the block) so it never sits on top of code regardless of code-block height.
    4. Verify single-line and multi-line cases both look correct (single-line is the regressing case in this issue; the multiline wrapper has slightly larger offsets but still overlaps short code).

    What alternative solutions did you explore? (Optional)

    Render the copy button in a sticky/floating toolbar above the code block on hover instead of overlaying it, mirroring common code-block UX (GitHub, VS Code Web).

  13. 7 remaining items

  14. David-2002065 commented on Jun 29, 2026

    @David-2002065
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On web, hovering a sent code‑block message (e.g. a triple‑backtick ```test```) shows the copy‑to‑clipboard icon directly on top of the code text, hiding it. Worst case is a short single‑line block where the icon covers the entire content.

    What is the root cause of that problem?

    This is a regression from the "copy code block on hover" feature added in PR #94337 (staging only, hence not reproducible in production).

    On hover, PreRenderer renders a CopyTextToClipboard button as an absolutely‑positioned overlay pinned to the block's top‑right corner:

    {isHovered && !!codeText && (
    <View style={isMultilineCodeBlock ? styles.codeBlockCopyButtonWrapperMultiline : styles.codeBlockCopyButtonWrapper}>
    <CopyTextToClipboard
    urlToCopy={codeText}
    styles={styles.copyableTextFieldButton}
    iconStyles={styles.t0}
    shouldHaveActiveBackground
    shouldUseButtonBackground
    />
    </View>
    )}

    The wrappers pin it at right: 4 (single‑line) / right: 8 (multi‑line), and the button is a solid 28×28 (it carries its own background via shouldUseButtonBackground):

    App/src/styles/index.ts

    Lines 6129 to 6147 in 50ff928

    copyableTextFieldButton: {
    width: 28,
    height: 28,
    borderRadius: variables.buttonBorderRadius,
    justifyContent: 'center',
    alignItems: 'center',
    },
    // Single-line code blocks keep the copy button tight to the corner.
    codeBlockCopyButtonWrapper: {
    position: 'absolute',
    top: 4,
    right: 4,
    },
    // Multi-line code blocks get extra breathing room around the copy button.
    codeBlockCopyButtonWrapperMultiline: {
    position: 'absolute',
    top: 8,
    right: 8,
    },

    The problem is the geometry of the block underneath. A <pre> is content‑sized — it has only paddingHorizontal: 12 and reserves no horizontal room on the right:

    App/src/styles/index.ts

    Lines 210 to 218 in 50ff928

    pre: {
    ...baseCodeTagStyles(theme),
    paddingVertical: 8,
    paddingHorizontal: 12,
    fontSize: undefined,
    ...FontUtils.fontFamily.platform.MONOSPACE,
    marginTop: 0,
    marginBottom: 0,
    },

    So the bordered box shrinks to fit its text, and the box's right edge falls right after the last character. The opaque 28px button pinned 4px from that edge therefore always paints over the trailing code, and for a short single‑line block the trailing code is the whole message — so the icon hides test entirely.

    What changes do you think we should make in order to solve the problem?

    The overlay design from #94337 is intentional, so I'd keep the button where it is and instead reserve a right‑hand gutter on the <pre> so the text never renders under the button. The button only ever appears on hover (and only on hover‑capable platforms — Hoverable never fires on native), so the gutter should be reserved on the same isHovered condition, not permanently. This keeps every code block visually unchanged at rest and on native, and the reserved space opens up exactly when the button fades in.

    The inner TDefaultRenderer is what renders the bordered <pre> box, and it already accepts a style prop (the task‑title branch passes one). So I'd pass a hover‑gated gutter style to it:

    <TDefaultRenderer
        {...defaultRendererProps}
        style={isHovered ? styles.codeBlockHoverGutter : undefined}
    />

    with a new shared style sized to clear the button (button 28px + its right inset + a small gap, on top of the existing 12px padding):

    codeBlockHoverGutter: {
        paddingRight: 40,
    },

    This pushes the code text left only while hovered, so the absolutely‑positioned button lands over the reserved padding instead of over the code, fixing both the single‑line and multi‑line cases. The exact paddingRight (and, if we want to mirror the two wrapper insets, sizing it per isMultilineCodeBlock) can be finalized in the PR.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • Render a single‑line code‑block comment, simulate hover, and assert the copy button (CopyTextToClipboard-CopyButton) renders and the <pre> receives the reserved gutter style so the text is not under the button.
    • Same for a multi‑line code block.
    • Assert that with no hover (and on native, where Hoverable reports no hover) no gutter is applied, so the block renders exactly as before.

    What alternative solutions did you explore? (Optional)

    • Reserve the gutter permanently (apply paddingRight to the <pre> unconditionally). This is simpler and avoids any hover‑time motion, but it leaves every code block — including non‑hovered blocks and native, where the button never shows — with a permanently lopsided empty gutter on the right. Gating the gutter to isHovered matches the button's own visibility and avoids that.
    • Move the button into a flexDirection: 'row' next to the <pre>. This guarantees no overlap, but reintroduces a vertical/wrapping layout shift on hover and complicates narrow screens — the absolute overlay from Add one-click copy button to code blocks in chat #94337 exists specifically to avoid that.
    • Remove the copy button from chat code blocks. This "fixes" the overlap by deleting the feature Add one-click copy button to code blocks in chat #94337 deliberately shipped for all fenced code blocks, so it isn't the right resolution.
  15. github-actions commented on Jun 29, 2026

    @github-actions
    Contributor

    ⚠️ @dilshodmackbook-sketch Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  16. David-2002065 commented on Jun 29, 2026

    @David-2002065
    Contributor

    Proposal updated

  17. KJ21-ENG commented on Jun 29, 2026

    @KJ21-ENG
    Contributor

    ⚠️ @KJ21-ENG Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

    This was false flag, my proposal was already as per the tamplate but i think it got flagged due to having this '' hidde scaffolding from template. I have alreday removed it and informed here as well.

    @huult I updated my proposal after local validation and checking the surrounding proposals/context. The important finding after the initial implementation attempt is that removing the copy icon entirely is over-broad: PR #94337 intentionally added this copy affordance for fenced chat code blocks, so the bug is not the existence of the icon itself. The actual RCA is that the PR #94337 hover copy button is absolutely positioned over a content-sized <pre> with no reserved right-side space, which is why it covers short code like test.

    So the fix direction was updated too: keep the code-block copy affordance, leave CopyTextRenderer / copy-text untouched, and merge a small right gutter into the existing <pre> style on hover. That keeps the normal code-block styling intact while making the icon sit over padding instead of text.

    Comparison branch :- main...KJ21-ENG:KJ21-ENG/94868-codeblock-copy

    POW :-

    ezyZip.63.mp4
  18. abbasifaizan70 commented on Jun 29, 2026

    @abbasifaizan70
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  19. github-actions commented on Jun 29, 2026

    @github-actions
    Contributor

    ⚠️ @abbasifaizan70 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  20. PiyushChandra17 commented on Jun 29, 2026

    @PiyushChandra17
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-06-29 18:45:33 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Chat - Copy to clipboard icon is appearing over the code block text

    What is the root cause of that problem?

    1. The root cause is that in PreRender.tsx, we are rendering this CopyTextToClipboard component within this View that has style:

    <View style={isMultilineCodeBlock ? styles.codeBlockCopyButtonWrapperMultiline : styles.codeBlockCopyButtonWrapper}>

    1. Since this is single line code block then it falls back to styles.codeBlockCopyButtonWrapper

    2. This styles.codeBlockCopyButtonWrapper uses position: absolute

    App/src/styles/index.ts

    Lines 6137 to 6141 in 19f1bb3

    codeBlockCopyButtonWrapper: {
    position: 'absolute',
    top: 4,
    right: 4,
    },

    1. And the <pre> tag itself only reserves a flat symmetric padding
    pre: {
        ...
        paddingVertical: 8,
        paddingHorizontal: 12,
        ...
    },
    

    What changes do you think we should make in order to solve the problem?

    1. Reserve enough right side padding inside the <pre> box so there's enough room for the icon regardless of how short the snippet is here

    App/src/styles/index.ts

    Lines 210 to 218 in 19f1bb3

    pre: {
    ...baseCodeTagStyles(theme),
    paddingVertical: 8,
    paddingHorizontal: 12,
    fontSize: undefined,
    ...FontUtils.fontFamily.platform.MONOSPACE,
    marginTop: 0,
    marginBottom: 0,
    },

    1. Updated code:
    pre: {
        ...baseCodeTagStyles(theme),
        paddingVertical: 8,
        paddingHorizontal: 12,
    +   paddingRight: 40,
        fontSize: undefined,
        ...FontUtils.fontFamily.platform.MONOSPACE,
        marginTop: 0,
        marginBottom: 0,
    },

    What alternative solutions did you explore? (Optional)

    N/A

    Result

    Before

    Image|

    After

    Image

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  21. github-actions commented on Jun 29, 2026

    @github-actions
    Contributor

    ⚠️ @PiyushChandra17 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  22. wildan-m commented on Jun 30, 2026

    @wildan-m
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When hovering over a chat message that contains a code block, the "Copy to clipboard" icon is rendered on top of the code block text instead of sitting in empty space. For single-line / short code blocks this causes the icon to overlap and cover the last characters of the code.

    What is the root cause of that problem?

    The copy button shown on hover is an absolutely-positioned overlay placed in the top-right corner of the code block, but no horizontal space is reserved for it, so it sits directly over the code text.

    In PreRenderer, when the block is hovered the copy button is rendered inside a wrapper that is absolutely positioned at the top-right corner of the code block container:

    {isHovered && !!codeText && (
    <View style={isMultilineCodeBlock ? styles.codeBlockCopyButtonWrapperMultiline : styles.codeBlockCopyButtonWrapper}>
    <CopyTextToClipboard
    urlToCopy={codeText}
    styles={styles.copyableTextFieldButton}
    iconStyles={styles.t0}
    shouldHaveActiveBackground
    shouldUseButtonBackground
    />
    </View>
    )}

    The wrapper styles only set position: 'absolute' with a small top/right offset; they do not push the code text out of the way:

    App/src/styles/index.ts

    Lines 6136 to 6147 in 552b726

    // Single-line code blocks keep the copy button tight to the corner.
    codeBlockCopyButtonWrapper: {
    position: 'absolute',
    top: 4,
    right: 4,
    },
    // Multi-line code blocks get extra breathing room around the copy button.
    codeBlockCopyButtonWrapperMultiline: {
    position: 'absolute',
    top: 8,
    right: 8,
    },

    The code block (pre) itself only has paddingHorizontal: 12:

    App/src/styles/index.ts

    Lines 210 to 218 in 552b726

    pre: {
    ...baseCodeTagStyles(theme),
    paddingVertical: 8,
    paddingHorizontal: 12,
    fontSize: undefined,
    ...FontUtils.fontFamily.platform.MONOSPACE,
    marginTop: 0,
    marginBottom: 0,
    },

    The copy button is 28px wide (copyableTextFieldButton) and is offset 4–8px from the right edge, so its footprint (~32–36px) extends well past the 12px of right padding and lands on top of the actual code characters. For a short single-line block such as test, there is no free space at the top-right, so the icon visibly covers the code text.

    What changes do you think we should make in order to solve the problem?

    Reserve horizontal space at the top-right of the code block for the copy button while it is displayed, so the icon occupies cleared space instead of overlapping the code text.

    In PreRenderer, when the copy button is shown (block hovered and codeText present), apply additional right padding to the code block content equal to the copy button's footprint. Because the button uses two offsets (single-line vs multiline), the reserved padding should match each case:

    • single-line block: reserve ~right(4) + buttonWidth(28) = ~32px,
    • multiline block: reserve ~right(8) + buttonWidth(28) = ~36px.

    Concretely, pass an extra right-padding style to the code block content (the <TDefaultRenderer> / surrounding Text container) only while the button is visible, and add two small style entries in src/styles/index.ts (e.g. codeBlockWithCopyButtonPadding / ...Multiline) holding the corresponding paddingRight values. The padding is applied alongside the existing isHovered && !!codeText condition that already gates the button, so the layout only reserves space exactly when the icon appears. This keeps the icon in the top-right corner over reserved empty space and guarantees it never sits over the code text, for both single-line and multiline blocks.

    What alternative solutions did you explore? (Optional)

    • Permanently reserve the right padding for every code block (not only on hover). This removes the on-hover reflow but leaves a visible empty gap on the right of every code block even when the button is not shown, which looks unintentional for short blocks.
    • Render the copy button beside the code block (outside its bounds) rather than as an overlay. This avoids overlap entirely but changes the established top-right corner placement and behaves inconsistently between content-width single-line blocks and full-width multiline blocks.
  23. github-actions commented on Jun 30, 2026

    @github-actions
    Contributor

    ⚠️ @wildan-m Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  24. huult commented on Jun 30, 2026

    @huult
    Contributor

    @MelvinBot Where is your proposal? Please create a proposal for this ticket.

  25. huult commented on Jun 30, 2026

    @huult
    Contributor

    Hover over the rendered code block and verify a copy icon button appears at the top-right (4px from top/right).

    Screen.Recording.2026-06-30.at.10.19.03.mov

    @Expensify/design @shawnborton This issue was introduced in #94337, and the current behavior appears to be expected. However, with shorter text, it still feels like a bug. Could you review this case and let me know whether we should keep the current behavior or make a change?

    If we change it to address this ticket, I think there are a couple of improvements we could make:

    1. Format the code text more like GitHub, as shown in the example below.
    test
    
    1. Add some spacing for the copy-to-clipboard icon, as shown in the video below.
    Screen.Recording.2026-06-30.at.10.21.14.mov
  26. shawnborton commented on Jun 30, 2026

    @shawnborton
    Contributor

    Not a bug, this is working as expected. Going to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions