Skip to content

Fixed issue where sorting icon would not show up in custom table headers#4300

Open
unaipme wants to merge 1 commit into
buefy:devfrom
unaipme:fix-table-custom-header-sort-icon
Open

Fixed issue where sorting icon would not show up in custom table headers#4300
unaipme wants to merge 1 commit into
buefy:devfrom
unaipme:fix-table-custom-header-sort-icon

Conversation

@unaipme

@unaipme unaipme commented Feb 13, 2026

Copy link
Copy Markdown

Fixes #2850.

The issue can still be reproduced with Buefy 3.0.4 in this CodeSandbox.

Proposed fix

Just changed the arrangement of the header slot so that the sort icon logic falls outside of the slot handling.

However, it could be argued that when the user creates a custom header using the #header slot, it's up to them to implement the icon too. Then, as this comment mentioned in the original issue (back in 2020, what a year that was):

If the decision is made to not add the arrows back in, perhaps something could be added to the documentation showing how to add them back in manually inside the custom template, if that's even possible.

I think this solution would be messier, as we would have to pass a callback method or something as a prop to the slot, nevermind having to update the docs! (For legal reasons, this is a joke) Obviously, feel free to reject this PR if you do agree with the quote.

@netlify

netlify Bot commented Feb 13, 2026

Copy link
Copy Markdown

Deploy Preview for buefyv3 ready!

Name Link
🔨 Latest commit a3e51f9
🔍 Latest deploy log https://app.netlify.com/projects/buefyv3/deploys/698f56b81d55ac00082b45ac
😎 Deploy Preview https://deploy-preview-4300--buefyv3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes BTable header rendering so the sort indicator icon is not suppressed when a column uses a custom #header slot (issue #2850).

Changes:

  • Moves sort icon rendering out of the default header-label branch so it can render alongside custom header slot content.
  • Preserves multi-sort icon/cancel UI by rendering it as a sibling to the header slot/label.

Comment on lines +125 to +142
<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"
both
:size="sortIconSize"
:class="{
'is-desc': sortMultipleDataComputed
.filter(i => i.field === column.field)[0]
.order === 'desc'}"
/>

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The multi-sort header rendering repeatedly calls sortMultipleDataComputed.filter(i => i.field === column.field) in both the v-if condition and the icon class binding. Since this block now runs even when column.$slots.header is used, this adds avoidable per-render allocations for each column. Consider replacing the filter(...).length > 0 check with some(...) and using a single find(...) result (or a computed lookup map keyed by field) for both the direction and index to avoid multiple scans.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply the requested change here

Comment on lines 121 to +125
</template>
<template v-else>
{{ 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"
both
:size="sortIconSize"
:class="{
'is-desc': sortMultipleDataComputed
.filter(i => i.field === column.field)[0]
.order === 'desc'}"
/>
{{ findIndexOfSortData(column) }}
<button
class="delete is-small multi-sort-cancel-icon"
type="button"
@click.stop="removeSortingPriority(column)"
/>
</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>
<template

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes UI behavior (sort icons now render even with a custom #header slot), but there’s no unit test covering it. Please add a Table test that mounts a sortable column with a header slot and asserts the .sort-icon (or multi-sort icons) are present/visible when the column is the current sort, to prevent regressions of #2850.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table with default sortable header hides arrow icon

3 participants