From 40e18fbc88d7fd6851c2f78a819e660557b6161c Mon Sep 17 00:00:00 2001 From: metonym Date: Sun, 29 May 2022 08:16:17 -0700 Subject: [PATCH] feat: set title attribute in `CheckBox`, `MultiSelect`, `Dropdown`, `ComboBox` if label is truncated (#1317) * feat(checkbox): set title attribute if label is truncated * feat(list-box-menu-item): set title attribute if label is truncated --- src/Checkbox/Checkbox.svelte | 6 ++++++ src/ListBox/ListBoxMenuItem.svelte | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Checkbox/Checkbox.svelte b/src/Checkbox/Checkbox.svelte index 5f6c74c7..41334148 100644 --- a/src/Checkbox/Checkbox.svelte +++ b/src/Checkbox/Checkbox.svelte @@ -62,6 +62,11 @@ $: useGroup = Array.isArray(group); $: checked = useGroup ? group.includes(value) : checked; $: dispatch("check", checked); + + let refLabel = null; + + $: isTruncated = refLabel?.offsetWidth < refLabel?.scrollWidth; + $: title = isTruncated ? refLabel?.innerText : title; @@ -109,6 +114,7 @@ />