Skip to content

Commit 501204c

Browse files
committed
fix: overflow responsive error
1 parent 3a93f19 commit 501204c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

components/vc-overflow/Overflow.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const Overflow = defineComponent({
9999
const mergedRestWidth = computed(() => Math.max(prevRestWidth.value, restWidth.value));
100100

101101
// ================================= Data =================================
102-
const isResponsive = computed(() => props.data.length && props.maxCount === RESPONSIVE);
102+
const isResponsive = computed(() => !!(props.data.length && props.maxCount === RESPONSIVE));
103103
const invalidate = computed(() => props.maxCount === INVALIDATE);
104104

105105
/**
@@ -183,7 +183,7 @@ const Overflow = defineComponent({
183183

184184
// ================================ Effect ================================
185185
const getItemWidth = (index: number) => {
186-
return itemWidths.value.get(getKey(mergedData[index], index));
186+
return itemWidths.value.get(getKey(mergedData.value[index], index));
187187
};
188188

189189
watch(
@@ -215,8 +215,11 @@ const Overflow = defineComponent({
215215
totalWidth += currentItemWidth;
216216

217217
if (
218-
i === lastIndex - 1 &&
219-
totalWidth + getItemWidth(lastIndex)! <= mergedContainerWidth.value
218+
// Only one means `totalWidth` is the final width
219+
(lastIndex === 0 && totalWidth <= mergedContainerWidth.value) ||
220+
// Last two width will be the final width
221+
(i === lastIndex - 1 &&
222+
totalWidth + getItemWidth(lastIndex)! <= mergedContainerWidth.value)
220223
) {
221224
// Additional check if match the end
222225
updateDisplayCount(lastIndex);
@@ -228,11 +231,6 @@ const Overflow = defineComponent({
228231
suffixFixedStart.value =
229232
totalWidth - currentItemWidth - suffixWidth.value + restWidth.value;
230233
break;
231-
} else if (i === lastIndex) {
232-
// Reach the end
233-
updateDisplayCount(lastIndex);
234-
suffixFixedStart.value = totalWidth - suffixWidth.value;
235-
break;
236234
}
237235
}
238236

0 commit comments

Comments
 (0)