Skip to content

ClipboardCopy - Allow truncate flexibility #10890

@gitdallas

Description

@gitdallas

ClipboardCopy currently truncates at the end. It may be nice in some cases to truncate at the start or middle (similar to how Truncate component works).

A workaround could currently work with inline-compact with some hacking, see https://codesandbox.io/p/sandbox/red-wind-zdgyqf

    <ClipboardCopy
      variant={"inline-compact"}
      style={{ display: "inline-flex" }}
      clickTip="Copied"
      onCopy={() => {
        navigator.clipboard.writeText(textToCopy);
      }}
    >
      <Truncate
        content={textToCopy}
        trailingNumChars={10}
        position={"middle"}
      />
    </ClipboardCopy>

However, this wouldn't work with other variants. They all use TextInput, as part of this feature I believe TextInput would also have to be updated to work with middle truncate (currently it only has start/end).

Could use props like truncatePosition, and truncateTrailingNumChars for middle.

This came up in a slack conversation with Vince Consola and @christianvogt

It would also be nice if inline-compact supported truncate by itself as well.

Metadata

Metadata

Assignees

Labels

No labels
No labels
No fields configured for Feature.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions