mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
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
This commit is contained in:
parent
90477c4d0e
commit
40e18fbc88
2 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
|
@ -109,6 +114,7 @@
|
|||
/>
|
||||
<label for="{id}" title="{title}" class:bx--checkbox-label="{true}">
|
||||
<span
|
||||
bind:this="{refLabel}"
|
||||
class:bx--checkbox-label-text="{true}"
|
||||
class:bx--visually-hidden="{hideLabel}"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue