mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(code-snippet): showMoreLess should update if code changes
This commit is contained in:
parent
ba5462072c
commit
0f6d42eb42
1 changed files with 8 additions and 1 deletions
|
@ -99,15 +99,22 @@
|
|||
*/
|
||||
export let ref = null;
|
||||
|
||||
import { tick } from "svelte";
|
||||
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16";
|
||||
import { Button } from "../Button";
|
||||
import { Copy } from "../Copy";
|
||||
import { CopyButton } from "../CopyButton";
|
||||
import CodeSnippetSkeleton from "./CodeSnippet.Skeleton.svelte";
|
||||
|
||||
function setShowMoreLess() {
|
||||
const { height } = ref.getBoundingClientRect();
|
||||
if (height > 0) showMoreLess = ref.getBoundingClientRect().height > 255;
|
||||
}
|
||||
|
||||
$: expandText = expanded ? showLessText : showMoreText;
|
||||
$: if (type === "multi" && ref) {
|
||||
showMoreLess = ref.getBoundingClientRect().height > 255;
|
||||
if (code === undefined) setShowMoreLess();
|
||||
if (code) tick().then(setShowMoreLess);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue