carbon-design-system / carbon-components-vue

Vue implementation of the Carbon Design System
http://vue.carbondesignsystem.com
Apache License 2.0
598 stars 177 forks source link

fix: CvDataTable did not properly store/emit sort events #1543

Closed markusdobler closed 8 months ago

markusdobler commented 8 months ago

What was broken?

Clicking on a sortable header in a CvDataTable (e.g. the first two columns in the official story book didn't actually trigger the expected events:

Why ?

The code that emits cv:sort when clicking on a CvDataTableHeading uses the key value:

function onSortClick() {
  bus?.emit('cv:sort', {
    heading: { id: cvId.value, name: props.name },
    value: nextOrder[internalOrder.value],
  });
}

However, the receiving code destructs payload into a variable named val:

function onSort(payload) {
  const { heading, val } = payload;

As val doesn't acutally exist in the payload, the variable gets initialized to undefined, breaking the rest of that function.

What did you do?

Changed the code in onSort(payload) to use the variable named value instead of val.

How have you tested it?

Were docs updated if needed?

davidnixon commented 8 months ago

Thanks for the fix!