fix(table): 改进表格自动调整大小的处理 (#2284)

* fix(table): 修复表格列宽计算一些边缘情况

* fix(table): 改进自动调整大小的处理
This commit is contained in:
morning-star 2024-11-04 17:22:13 +08:00 committed by GitHub
parent c10837393b
commit 7869687e81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -501,7 +501,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
try {
isNone = parent.css('display') === 'none';
} catch(e){}
if(parent[0] && !lay.isTopElem(parent[0]) && (!width || isNone)) return getWidth(parent.parent());
var parentElem = parent.parent();
if(parent[0] && parentElem && parentElem.nodeType === 1 && (!width || isNone)) return getWidth(parentElem);
return width;
};
return getWidth();
@ -1060,7 +1061,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
Class.prototype.resize = function(){
var that = this;
if (!that.layMain) return;
var tableElemIsConnected = that.layMain && ('isConnected' in that.layMain[0]
? that.layMain[0].isConnected
: $.contains(document.body, that.layMain[0]));
if(!tableElemIsConnected) return;
that.fullSize(); // 让表格铺满
that.setColsWidth(); // 自适应列宽