diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index d84d32f..823d0c0 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -16,7 +16,7 @@ import { GridColumn, GridInputColumn, GridTextColumn, GridDropdownColumn, GridCh * @version 1.0.2 */ -const ScriptPath = (self.document == null ? self.location.href : self.document.currentScript.src).replace(/ui\.min\.js\?.+$/, ''); +const ScriptPath = (self.document == null ? self.location.href : self.document.currentScript?.src ?? '').replace(/ui\.min\.js\?.+$/, ''); const Encoder = new TextEncoder('utf-8'); const ColumnChangedType = { @@ -612,7 +612,7 @@ export class Grid { * @type {KeyMap} * @private */ - enabledDict: {}, + enabledDict: null, /** * 合计行数据 * @type {GridRowItem} @@ -752,6 +752,12 @@ export class Grid { * @private */ needResize: null, + /** + * 提示条消失的 Timer + * @type {number} + * @private + */ + tooltipTimer: null, /** * 页面元素引用 * @private @@ -1331,6 +1337,7 @@ export class Grid { this._var.rendering = true; this._var.parent = container; this._var.isFirefox = /Firefox\//i.test(navigator.userAgent); + this._var.enabledDict = {}; const grid = createElement('div', 'ui-grid'); grid.setAttribute('tabindex', 0); grid.addEventListener('keydown', e => { @@ -1418,6 +1425,7 @@ export class Grid { const col = Number(holder.dataset.col); if (holder.classList.contains('active')) { holder.classList.remove('active'); + this._clearHolder(holder); } return this._onRowClicked(e, row, col); }); @@ -3896,6 +3904,22 @@ export class Grid { } } + /** + * 清除 tooltip 显示框,并延时后设置 `display: none` + * 不设置 display 的话会导致元素依然被算入滚动范围,从而影响滚动条显示 + * @private + * @param {HTMLDivElement} holder + */ + _clearHolder(holder) { + if (this._var.tooltipTimer != null) { + clearTimeout(this._var.tooltipTimer); + } + this._var.tooltipTimer = setTimeout(() => { + holder.style.display = 'none'; + this._var.tooltipTimer = null; + }, 120); + } + /** * @private * @param {MouseEvent} e @@ -3912,6 +3936,7 @@ export class Grid { delete holder.dataset.col; if (holder.classList.contains('active')) { holder.classList.remove('active'); + this._clearHolder(holder); } return; } @@ -3931,6 +3956,7 @@ export class Grid { delete holder.dataset.col; if (holder.classList.contains('active')) { holder.classList.remove('active'); + this._clearHolder(holder); } return; } @@ -3943,6 +3969,7 @@ export class Grid { delete holder.dataset.row; delete holder.dataset.col; holder.classList.remove('active'); + this._clearHolder(holder); } return; } @@ -3968,6 +3995,7 @@ export class Grid { delete holder.dataset.row; delete holder.dataset.col; holder.classList.remove('active'); + this._clearHolder(holder); } }