Skip to content

Commit 34c60fe

Browse files
committed
fix: fix CTable sorting icon positioning
1 parent f82a513 commit 34c60fe

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

src/components/Table/CTable.vue

+30-16
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,28 @@
3636
<tr>
3737
<th v-if="indexCol" style="width:40px"></th>
3838
<template v-for="(name, index) in columnNames">
39-
<th @click="changeSort(rawColumnNames[index], index)"
40-
:class="headerClass(index)"
41-
:style="headerStyles(index)"
39+
<th
40+
@click="changeSort(rawColumnNames[index], index)"
41+
:class="[headerClass(index), iconStyles]"
42+
:style="headerStyles(index)"
4243
>
4344
<slot v-if="$slots[`${rawColumnNames[index]}-header`]"
4445
:name="`${rawColumnNames[index]}-header`"
4546
>
4647
</slot>
4748
<div v-else v-html="name" class="d-inline"></div>
48-
<slot v-if="!noSorting && sortable(index)" name="sorting-icon" :state="getIconState(index)">
49-
<i :class="iconClasses(index)"></i>
49+
<slot
50+
v-if="!noSorting && sortable(index)"
51+
name="sorting-icon"
52+
:state="getIconState(index)"
53+
>
54+
<i style="right:0px;" :class="iconClasses(index)"></i>
5055
</slot>
5156
</th>
5257
</template>
5358
</tr>
5459
<tr v-if="filterRow" class="table-sm">
55-
<th v-if="indexCol"class="pb-2 ">
60+
<th v-if="indexCol" class="pb-2">
5661
<i v-if="indexCol !== 'onlyIndexes'" class="cui-ban icons text-danger font-lg text-center d-block" @click="clear" title="clear table"></i>
5762
</th>
5863
<template v-for="(colName, index) in rawColumnNames" >
@@ -125,20 +130,26 @@
125130
</td>
126131
</tr>
127132
</tbody>
128-
<tfoot v-if="footClone && currentItems.length > 3">
133+
<tfoot v-if="footer && currentItems.length > 3">
129134
<tr>
130135
<th v-if="indexCol" style="width:40px"></th>
131136
<template v-for="(name, index) in columnNames">
132137
<th @click="changeSort(rawColumnNames[index], index)"
133-
:class="headerClass(index)"
138+
:class="[headerClass(index), iconStyles]"
134139
:style="headerStyles(index)"
135140
>
136-
<slot :name="`${rawColumnNames[index]}-header`">
137-
{{name}}
138-
</slot>
139-
<slot v-if="!noSorting && sortable(index)" name="sorting-icon" :state="getIconState(index)">
140-
<i :class="iconClasses(index)"></i>
141-
</slot>
141+
<slot v-if="$slots[`${rawColumnNames[index]}-header`]"
142+
:name="`${rawColumnNames[index]}-header`"
143+
>
144+
</slot>
145+
<div v-else v-html="name" class="d-inline"></div>
146+
<slot
147+
v-if="!noSorting && sortable(index)"
148+
name="sorting-icon"
149+
:state="getIconState(index)"
150+
>
151+
<i style="right:0px;" :class="iconClasses(index)"></i>
152+
</slot>
142153
</th>
143154
</template>
144155
</tr>
@@ -193,7 +204,7 @@ export default {
193204
border: Boolean,
194205
outlined: Boolean,
195206
optionsRow: [Boolean, String],
196-
footClone: Boolean,
207+
footer: Boolean,
197208
defaultSorter: {
198209
type: Object,
199210
default: () => ({ name:'', direction:''})
@@ -307,6 +318,9 @@ export default {
307318
const size = this.small ? '1.4rem' : this.currentItems.length === 1 ? '2rem' : '3rem'
308319
return `width:${size};height:${size}`
309320
},
321+
iconStyles () {
322+
return !this.noSorting ? 'position-relative pr-4' : ''
323+
}
310324
// loadingStyles () {
311325
// return !this.loading ? '' :
312326
// `opacity: .4; ${this.loading === 'noEvents' ? 'pointer-events:none' : ''}`
@@ -400,7 +414,7 @@ export default {
400414
},
401415
iconClasses (index) {
402416
const state = this.getIconState(index)
403-
return [ 'icon-transition float-right icons font-xl cui-arrow-top',
417+
return [ 'icon-transition float-right icons font-xl cui-arrow-top position-absolute',
404418
{
405419
'transparent': !state,
406420
'rotate-icon': state === 'desc'

0 commit comments

Comments
 (0)