Skip to content

Commit 67d6eef

Browse files
committed
feat: copy only from other element if there is no 'value' field
1 parent 11479a8 commit 67d6eef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/uui-text-copy/lib/uui-button-copy-text.element.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ export class UUIButtonCopyTextElement extends UUIButtonElement {
6464
// Try & find an element with the ID
6565
const el = document.getElementById(this.copyFrom);
6666
if (el) {
67-
valueToCopy = el.textContent ?? el.innerText ?? '';
68-
69-
// Override the value to copy ,if the element has a value property
67+
// Override the value to copy, if the element has a value property
7068
// Such as uui-input or uui-textarea or native inout elements
7169
if ('value' in el) {
7270
valueToCopy = (el as any).value;
71+
} else {
72+
valueToCopy = el.textContent ?? el.innerText ?? '';
7373
}
7474
} else {
7575
console.error(`Element ID ${this.copyFrom} not found to copy from`);

0 commit comments

Comments
 (0)