Skip to content

Commit

Permalink
fix: overflow responsive error
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jun 21, 2021
1 parent 3a93f19 commit 501204c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/vc-overflow/Overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Overflow = defineComponent({
const mergedRestWidth = computed(() => Math.max(prevRestWidth.value, restWidth.value));

// ================================= Data =================================
const isResponsive = computed(() => props.data.length && props.maxCount === RESPONSIVE);
const isResponsive = computed(() => !!(props.data.length && props.maxCount === RESPONSIVE));
const invalidate = computed(() => props.maxCount === INVALIDATE);

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ const Overflow = defineComponent({

// ================================ Effect ================================
const getItemWidth = (index: number) => {
return itemWidths.value.get(getKey(mergedData[index], index));
return itemWidths.value.get(getKey(mergedData.value[index], index));
};

watch(
Expand Down Expand Up @@ -215,8 +215,11 @@ const Overflow = defineComponent({
totalWidth += currentItemWidth;

if (
i === lastIndex - 1 &&
totalWidth + getItemWidth(lastIndex)! <= mergedContainerWidth.value
// Only one means `totalWidth` is the final width
(lastIndex === 0 && totalWidth <= mergedContainerWidth.value) ||
// Last two width will be the final width
(i === lastIndex - 1 &&
totalWidth + getItemWidth(lastIndex)! <= mergedContainerWidth.value)
) {
// Additional check if match the end
updateDisplayCount(lastIndex);
Expand All @@ -228,11 +231,6 @@ const Overflow = defineComponent({
suffixFixedStart.value =
totalWidth - currentItemWidth - suffixWidth.value + restWidth.value;
break;
} else if (i === lastIndex) {
// Reach the end
updateDisplayCount(lastIndex);
suffixFixedStart.value = totalWidth - suffixWidth.value;
break;
}
}

Expand Down

0 comments on commit 501204c

Please sign in to comment.