Skip to content

Commit

Permalink
clean up datarow interactions when both selectable and with kebab
Browse files Browse the repository at this point in the history
  • Loading branch information
joepavitt committed Mar 15, 2023
1 parent 8a905cd commit 5415aca
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/DesignLanguage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<pre style="display:inline;">.stop</pre> event modifier on the event handlers. This is important if
<pre style="display:inline;">:rows-selectable="true"</pre> to prevent the click event bubbling up to the row.
</p>
<ff-data-table :columns="data.table0.columns" :rows="data.table0.rows">
<ff-data-table :columns="data.table0.columns" :rows="data.table0.rows" :rows-selectable="true" @row-selected="doSomething">
<template v-slot:context-menu>
<ff-list-item label="Option 1" @click.stop=""/>
<ff-list-item label="Option 2" @click.stop=""/>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/table.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}, {
"code": "<ff-data-table :columns=\"cols\" :rows=\"rows\" :rows-selectable=\"true\" @row-selected=\"doSomething\"></ff-data-table>"
}, {
"code": "<ff-data-table :columns=\"cols\" :rows=\"rows\">\n\t<template v-slot:context-menu=\"{row}\">\n\t\t<ff-list-item label=\"Option 1\" @click.stop=\"doSomething(row)\"/>\n\t\t<ff-list-item label=\"Option 2\" @click.stop=\"doSomething(row)\"/>\n\t\t<ff-list-item label=\"Option 3\" @click.stop=\"doSomething(row)\"/>\n\t</template>\n</ff-data-table>"
"code": "<ff-data-table :columns=\"cols\" :rows=\"rows\" :rows-selectable=\"true\" @row-selected=\"doSomething\">\n\t<template v-slot:context-menu=\"{row}\">\n\t\t<ff-list-item label=\"Option 1\" @click.stop=\"doSomething(row)\"/>\n\t\t<ff-list-item label=\"Option 2\" @click.stop=\"doSomething(row)\"/>\n\t\t<ff-list-item label=\"Option 3\" @click.stop=\"doSomething(row)\"/>\n\t</template>\n</ff-data-table>"
}, {
"code": "<ff-data-table :columns=\"cols\" :rows=\"rows\" :show-search=\"true\"\n\tsearch-placeholder=\"Search here...\" v-model:search=\"search\">\n\t<template v-slot:actions>\n\t\t<ff-button>Press Me!</ff-button>\n\t\t<ff-button>Click Me!</ff-button>\n\t</template>\n</ff-data-table>"
}, {
Expand Down
2 changes: 1 addition & 1 deletion src/components/data-table/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ff-data-table-row>
<template v-if="!loading">
<ff-data-table-row v-for="(r, $index) in filteredRows" :key="$index" :data="r" :columns="columns"
:selectable="rowsSelectable" :highlight-cell="sort.highlightColumn" @click="rowClick(r)"
:selectable="rowsSelectable" :highlight-cell="sort.highlightColumn" @selected="rowClick(r)"
>
<template v-if="hasContextMenu" #context-menu="{row}">
<slot name="context-menu" :row="row"></slot>
Expand Down
8 changes: 4 additions & 4 deletions src/components/data-table/DataTableRow.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<tr class="ff-data-table--row" :class="{'selectable': selectable}" @click="$emit('selected', data)">
<tr class="ff-data-table--row" :class="{'selectable': selectable}">
<slot>
<ff-data-table-cell v-for="(col, $column) in columns" :key="col.label" :class="col.class" :style="col.style" :highlight="highlightCell === $column">
<ff-data-table-cell v-for="(col, $column) in columns" :key="col.label" :class="col.class" :style="col.style" :highlight="highlightCell === $column" @click="$emit('selected', data)">
<template v-if="col.component">
<component :is="col.component.is" v-bind="{...col.component.extraProps ?? {}, ...getCellData(data, col)}"></component>
</template>
Expand All @@ -13,8 +13,8 @@
</template>
</ff-data-table-cell>
</slot>
<ff-data-table-cell v-if="hasContextMenu" style="width: 50px">
<ff-kebab-menu menu-align="right">
<ff-data-table-cell v-if="hasContextMenu" style="width: 50px" @click="$refs.kebab.openOptions()">
<ff-kebab-menu ref="kebab" menu-align="right">
<slot name="context-menu" :row="data" message="hello world"></slot>
</ff-kebab-menu>
</ff-data-table-cell>
Expand Down
2 changes: 2 additions & 0 deletions src/stylesheets/ff-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
}

.ff-kebab-options {
color: $ff-grey-800;
position: absolute;
top: 24px;
border: 1px solid $ff-grey-300;
Expand Down Expand Up @@ -647,6 +648,7 @@ li.ff-list-item {
}
.selectable:hover .ff-data-table--cell {
cursor: pointer;
color: $ff-blue-600;
background-color: $ff-grey-50;
}
}
Expand Down

0 comments on commit 5415aca

Please sign in to comment.