mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
feat(list-box-menu-item): set title attribute if label is truncated
This commit is contained in:
parent
028054eaff
commit
53acd58117
1 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
/** Set to `true` to enable the highlighted state */
|
/** Set to `true` to enable the highlighted state */
|
||||||
export let highlighted = false;
|
export let highlighted = false;
|
||||||
|
|
||||||
|
let ref = null;
|
||||||
|
|
||||||
|
$: isTruncated = ref?.offsetWidth < ref?.scrollWidth;
|
||||||
|
$: title = isTruncated ? ref?.innerText : undefined;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -15,7 +20,11 @@
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
on:mouseleave
|
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 />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue