fix: hoverContent的key改变获取方式

This commit is contained in:
gx 2021-05-06 11:23:28 +08:00
parent 9dcc149966
commit 68a1f6217c
5 changed files with 25 additions and 16 deletions

View File

@ -1736,6 +1736,8 @@ var Table = function (_Component) {
};
Table.prototype.handleRowHover = function handleRowHover(isHover, key, event, currentIndex, propsRecord) {
var _this7 = this;
//增加新的API设置是否同步Hover状态提高性能避免无关的渲染
var _props11 = this.props,
syncHover = _props11.syncHover,
@ -1746,8 +1748,9 @@ var Table = function (_Component) {
var isTreeType = this.isTreeType;
var record = isTreeType ? propsRecord : lazyLoad ? data.find(function (item) {
return item.key === key;
var record = isTreeType ? propsRecord : lazyLoad ? data.find(function (item, index) {
var rowKey = item.key ? item.key : _this7.getRowKey(item, index);
return rowKey === key;
}) : data[currentIndex];
// 固定列、或者含有hoverdom时情况下同步hover状态
if (this.columnManager.isAnyColumnsFixed() && syncHover) {
@ -1781,7 +1784,7 @@ var Table = function (_Component) {
};
Table.prototype.render = function render() {
var _this7 = this;
var _this8 = this;
var _state3 = this.state,
currentHoverRecord = _state3.currentHoverRecord,
@ -1834,7 +1837,7 @@ var Table = function (_Component) {
return _react2["default"].createElement(
'div',
{ className: className, style: props.style, ref: function ref(el) {
return _this7.contentTable = el;
return _this8.contentTable = el;
},
tabIndex: props.focusable && (props.tabIndex ? props.tabIndex : '0') },
this.getTitle(),
@ -1866,7 +1869,7 @@ var Table = function (_Component) {
'div',
{ className: 'u-row-hover',
onMouseEnter: this.onRowHoverMouseEnter, onMouseLeave: this.onRowHoverMouseLeave, ref: function ref(el) {
return _this7.hoverDom = el;
return _this8.hoverDom = el;
} },
currentHoverRecord ? props.hoverContent(currentHoverRecord, currentHoverIndex) : null
)

17
dist/demo.js vendored
View File

@ -49645,6 +49645,8 @@
};
Table.prototype.handleRowHover = function handleRowHover(isHover, key, event, currentIndex, propsRecord) {
var _this7 = this;
//增加新的API设置是否同步Hover状态提高性能避免无关的渲染
var _props11 = this.props,
syncHover = _props11.syncHover,
@ -49655,8 +49657,9 @@
var isTreeType = this.isTreeType;
var record = isTreeType ? propsRecord : lazyLoad ? data.find(function (item) {
return item.key === key;
var record = isTreeType ? propsRecord : lazyLoad ? data.find(function (item, index) {
var rowKey = item.key ? item.key : _this7.getRowKey(item, index);
return rowKey === key;
}) : data[currentIndex];
// 固定列、或者含有hoverdom时情况下同步hover状态
if (this.columnManager.isAnyColumnsFixed() && syncHover) {
@ -49690,7 +49693,7 @@
};
Table.prototype.render = function render() {
var _this7 = this;
var _this8 = this;
var _state3 = this.state,
currentHoverRecord = _state3.currentHoverRecord,
@ -49743,7 +49746,7 @@
return _react2['default'].createElement(
'div',
{ className: className, style: props.style, ref: function ref(el) {
return _this7.contentTable = el;
return _this8.contentTable = el;
},
tabIndex: props.focusable && (props.tabIndex ? props.tabIndex : '0') },
this.getTitle(),
@ -49775,7 +49778,7 @@
'div',
{ className: 'u-row-hover',
onMouseEnter: this.onRowHoverMouseEnter, onMouseLeave: this.onRowHoverMouseLeave, ref: function ref(el) {
return _this7.hoverDom = el;
return _this8.hoverDom = el;
} },
currentHoverRecord ? props.hoverContent(currentHoverRecord, currentHoverIndex) : null
)
@ -62643,8 +62646,8 @@
// }
var showScroll = contentDomWidth - (leftFixedWidth + rightFixedWidth) - (_this7.drag.tableWidth + diff) - scrollbarWidth;
var dargTableWidth = parseFloat(window.getComputedStyle(_this7.table.table).width);
var showScroll = contentDomWidth - (leftFixedWidth + rightFixedWidth) - (dargTableWidth + diff) - scrollbarWidth;
//表头滚动条处理
if (headerScroll) {
if (showScroll < 0) {

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-table",
"version": "2.3.15-beta.29",
"version": "2.3.15-beta.30",
"description": "Table ui component for react",
"keywords": [
"react",

View File

@ -1502,7 +1502,10 @@ class Table extends Component {
let { syncHover,onRowHover,data, lazyLoad } = this.props;
//fix:树形表onRowHover返回参数异常
let { isTreeType } = this;
const record = isTreeType ? propsRecord : lazyLoad ? data.find(item => item.key === key) : data[currentIndex];
const record = isTreeType ? propsRecord : lazyLoad ? data.find((item, index) => {
const rowKey = item.key ? item.key : this.getRowKey(item, index);
return rowKey === key
}) : data[currentIndex];
// 固定列、或者含有hoverdom时情况下同步hover状态
if(this.columnManager.isAnyColumnsFixed() && syncHover ){
this.hoverKey = key;