Skip to content

Commit

Permalink
fix(lib): sort icons on Table overlapped next columns
Browse files Browse the repository at this point in the history
- Fixes the issue that sort icons on Table overlapped or were clipped by
  next columns.

  Since sort icons were absolutely positioned and placed at the right
  side of the column label texts, the icons overlapped or were clipped
  by the right columns when columns were packed. This commit changes the
  anchor element for sort icons to `<div class="th-wrap">` elements that
  wrap the column label texts and absolutely places sort icons ON the
  right end of the `<div class="th-wrap">` elements instead. If the
  column `is-numeric`, the sort icon is placed on the left end of the
  `<div class="th-wrap">` element, otherwise the sort icon overlaps the
  column label text.

  Similar problems occurred when the `sort-multiple` option was turned
  on. Applying the above solution to the delete buttons of sort
  indicators did not work well. The delete buttons were torn apart from
  the sort icons since the sort icons aligned with the normal flow of
  the column label texts. I decided to group the sort icon, number, and
  delete button as `multi-sort-icons` so that they do not split.
  `multi-sort-icons` is placed in the normal flow of the column label
  texts and moves to the next line if the column is packed.

issues
- buefy#2886
- buefy#3034
  • Loading branch information
kikuomax committed Dec 19, 2023
1 parent 2598d47 commit 29a707d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
48 changes: 24 additions & 24 deletions src/components/table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
@dragover="handleColumnDragOver($event, column, index)"
@dragleave="handleColumnDragLeave($event, column, index)">
<div
class="th-wrap"
class="th-wrap is-relative"
:class="{
'is-numeric': column.numeric,
'is-centered': column.centered
Expand All @@ -110,14 +110,14 @@
/>
</template>
<template v-else>
<span class="is-relative">
{{ column.label }}
<template
v-if="sortMultiple &&
sortMultipleDataComputed &&
sortMultipleDataComputed.length > 0 &&
sortMultipleDataComputed.filter(i =>
i.field === column.field).length > 0">
{{ column.label }}
<template
v-if="sortMultiple &&
sortMultipleDataComputed &&
sortMultipleDataComputed.length > 0 &&
sortMultipleDataComputed.filter(i =>
i.field === column.field).length > 0">
<span class="multi-sort-icons">
<b-icon
:icon="sortIcon"
:pack="iconPack"
Expand All @@ -132,21 +132,21 @@
class="delete is-small multi-sort-cancel-icon"
type="button"
@click.stop="removeSortingPriority(column)"/>
</template>

<b-icon
v-else
:icon="sortIcon"
:pack="iconPack"
both
:size="sortIconSize"
class="sort-icon"
:class="{
'is-desc': !isAsc,
'is-invisible': currentSortColumn !== column
}"
/>
</span>
</span>
</template>

<b-icon
v-else
:icon="sortIcon"
:pack="iconPack"
both
:size="sortIconSize"
class="sort-icon"
:class="{
'is-desc': !isAsc,
'is-invisible': currentSortColumn !== column
}"
/>
</template>
</div>
</th>
Expand Down
18 changes: 13 additions & 5 deletions src/scss/components/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ $table-sticky-header-height: 300px !default;
font-weight: $weight-semibold;
.th-wrap {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
.icon {
margin-left: 0.5rem;
Expand All @@ -124,9 +126,11 @@ $table-sticky-header-height: 300px !default;
flex-direction: row-reverse;
text-align: right;
width: 95%;
.icon {
.sort-icon {
margin-left: 0;
margin-right: 0.5rem;
left: 0;
right: auto;
}
}
&.is-centered {
Expand All @@ -149,14 +153,18 @@ $table-sticky-header-height: 300px !default;
position: absolute;
}
}
.sort-icon, .multi-sort-cancel-icon {
.sort-icon {
position: absolute;
bottom: 50%;
left: 100%;
right: 0;
transform: translateY(50%);
}
.multi-sort-cancel-icon {
margin-left: 10px;
.multi-sort-icons {
display: flex;
align-items: center;
.multi-sort-cancel-icon {
margin-left: 10px;
}
}
&.is-sticky {
position: -webkit-sticky;
Expand Down

0 comments on commit 29a707d

Please sign in to comment.