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:
metonym 2022-05-29 08:16:17 -07:00 committed by GitHub
commit 40e18fbc88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -4,6 +4,11 @@
/** Set to `true` to enable the highlighted state */
export let highlighted = false;
let ref = null;
$: isTruncated = ref?.offsetWidth < ref?.scrollWidth;
$: title = isTruncated ? ref?.innerText : undefined;
</script>
<div
@ -15,7 +20,11 @@
on:mouseenter
on:mouseleave
>
<div class:bx--list-box__menu-item__option="{true}">
<div
bind:this="{ref}"
title="{title}"
class:bx--list-box__menu-item__option="{true}"
>
<slot />
</div>
</div>