Skip to content

Commit

Permalink
Fix Column picker Ctrl+A issue
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-giulianasilva committed Jul 26, 2024
1 parent 3d20a6a commit dbf21f3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Providers/DataGrid/Wijmo/Features/ColumnPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
private _configureCheckbox(col: OSFramework.DataGrid.Column.IColumn, item: HTMLElement) {
if (col.config.canBeHidden === false) {
const checkbox = item.querySelector('input[type="checkbox"]');
wijmo.toggleClass(item, 'wj-state-disabled', true);
if (checkbox) {
checkbox.setAttribute('disabled', 'true');
}
Expand Down Expand Up @@ -168,6 +169,39 @@ namespace Providers.DataGrid.Wijmo.Feature {
);
}

// This code fixes WJM-34234
private _issueWorkaround(e) {
if (e.ctrlKey && e.code === 'KeyA') {
const checkedItems = [...this._theColumnPicker.checkedItems];
this._theColumnPicker._children.forEach((item, index) => {
const input = item.querySelector('input');

// If the checkbox item is disabled
if ((input && input.disabled) || item.classList.contains('wj-state-disabled')) {
const data = this._theColumnPicker.collectionView.items[index];
const isVisible = this._grid.getColumn(data.binding).config.visible;

// Then check if the column must be visible
// If it is NOT included in the checked items, let's add to it
if (isVisible && !checkedItems.includes(data)) {
checkedItems.push(data);
}
// If the column must NOT be visible
// And it is included in the checked items, let's remove it
else if (!isVisible && checkedItems.includes(data)) {
const indexToRemove = checkedItems.indexOf(data);
checkedItems.splice(indexToRemove, 1);
}
}
});

// Updated the checkedItems array
this._theColumnPicker.checkedItems = checkedItems;
this._grid.provider.invalidate(true);
}
e.preventDefault();
}

private _makeColumnPicker(): void {
const theGrid = this._grid.provider;
const picker = document.createElement('div');
Expand Down Expand Up @@ -232,6 +266,9 @@ namespace Providers.DataGrid.Wijmo.Feature {

e.preventDefault();
};

// This code fixes WJM-34234
this._theColumnPicker.hostElement.addEventListener('keydown', this._issueWorkaround.bind(this));
}

public build(): void {
Expand Down

0 comments on commit dbf21f3

Please sign in to comment.