Skip to content

Commit 2d2ac51

Browse files
committed
Use Heading clamp prop for history name in DetailsLayout
Replaces the custom h3 + line-clamp CSS with the new Heading component's clamp prop for the non-renameable case. ClickToEdit still uses scoped CSS for the clamp since it renders its own h3.
1 parent bf73ed8 commit 2d2ac51

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

client/src/components/History/Layout/DetailsLayout.vue

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import l from "@/utils/localization";
1111
import type { DetailsLayoutSummarized } from "./types";
1212
1313
import ClickToEdit from "@/components/Collections/common/ClickToEdit.vue";
14+
import Heading from "@/components/Common/Heading.vue";
1415
import TextSummary from "@/components/Common/TextSummary.vue";
1516
import StatelessTags from "@/components/TagsMultiselect/StatelessTags.vue";
1617
@@ -40,8 +41,8 @@ const userStore = useUserStore();
4041
const { isAnonymous } = storeToRefs(userStore);
4142
4243
const nameRef = ref<HTMLInputElement | null>(null);
43-
const nameDisplayRef = ref<InstanceType<typeof ClickToEdit> | HTMLElement | null>(null);
44-
const nameClamped = ref(false);
44+
const clickToEditRef = ref<InstanceType<typeof ClickToEdit> | null>(null);
45+
const clickToEditClamped = ref(false);
4546
4647
const editing = ref(false);
4748
const textSelected = ref(false);
@@ -106,17 +107,17 @@ function onToggle() {
106107
}
107108
}
108109
109-
function checkNameClamped() {
110-
const el = nameDisplayRef.value instanceof HTMLElement ? nameDisplayRef.value : nameDisplayRef.value?.$el;
110+
function checkClickToEditClamped() {
111+
const el = clickToEditRef.value?.$el;
111112
if (el) {
112-
nameClamped.value = el.scrollHeight > el.clientHeight;
113+
clickToEditClamped.value = el.scrollHeight > el.clientHeight;
113114
}
114115
}
115116
116-
onMounted(checkNameClamped);
117+
onMounted(checkClickToEditClamped);
117118
watch(
118119
() => props.name,
119-
() => nextTick(checkNameClamped),
120+
() => nextTick(checkClickToEditClamped),
120121
);
121122
122123
function selectText() {
@@ -136,22 +137,17 @@ function selectText() {
136137
<template v-if="!summarized && !editing">
137138
<ClickToEdit
138139
v-if="renameable"
139-
ref="nameDisplayRef"
140+
ref="clickToEditRef"
140141
v-model="clickToEditName"
141-
v-b-tooltip.hover="nameClamped ? name : undefined"
142+
v-b-tooltip.hover="clickToEditClamped ? name : undefined"
142143
component="h3"
143144
title="..."
144145
data-description="name display"
145146
no-save-on-blur
146147
class="name-display my-2 w-100" />
147-
<h3
148-
v-else
149-
ref="nameDisplayRef"
150-
v-b-tooltip.hover
151-
:title="nameClamped ? name : undefined"
152-
class="name-display my-2 w-100">
148+
<Heading v-else h3 :clamp="2" class="my-2 w-100">
153149
{{ props.name || "..." }}
154-
</h3>
150+
</Heading>
155151
</template>
156152
<div v-else class="overflow-hidden" style="max-width: 80%">
157153
<TextSummary

0 commit comments

Comments
 (0)