-
Notifications
You must be signed in to change notification settings - Fork 672
PivotGrid: open header filter popup by hotkey #33994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,16 @@ export class FieldChooserBase extends mixinWidget { | |
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| protected _setAriaSortAttribute(_column, _ariaSortState, _$rootElement) { } | ||
|
|
||
| protected _applyColumnState(options) { | ||
| const $element = super._applyColumnState(options); | ||
|
|
||
| if (options.name === 'headerFilter' && $element) { | ||
| $element.removeAttr('tabindex'); | ||
| } | ||
|
|
||
| return $element; | ||
| } | ||
|
|
||
| _init() { | ||
| super._init(); | ||
| this._headerFilterView = new HeaderFilterView(this); | ||
|
|
@@ -358,14 +368,32 @@ export class FieldChooserBase extends mixinWidget { | |
| const targetElement = element ?? this.$element(); | ||
|
|
||
| const handler = (e) => { | ||
| const field: any = $(e.currentTarget).data('field'); | ||
|
|
||
| if (!field) { | ||
| return; | ||
| } | ||
|
|
||
| const isAltArrowDown = e.type === 'keydown' && e.altKey && e.key === 'ArrowDown'; | ||
|
|
||
| if (isAltArrowDown) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we have 2 places for opening header filter:
I suggest to unify them, remove the old logic and add to this condition a check for header filter icon click |
||
| const mainGroupField = getMainGroupField(this._dataSource, field); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we need
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see, because there can grouped fields, in which only the first group item has header filter. I see that the condition is similar to the condition for rendering header filter icon: Maybe create a helper function, which can be reused? isFieldHasHeaderFilter = (field) => {
const mainGroupField = // ...
const isFirstInGroup = (field.groupIndex === 0 || !isDefined(field.groupIndex);
return mainGroupField .allowFiltering && isFirstInGroup && field.area !== 'data';
} |
||
|
|
||
| if (mainGroupField.allowFiltering && field.area !== 'data' && !field.groupIndex) { | ||
| e.preventDefault(); | ||
| this.handleHeaderFilterIconClick(e, field); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const shouldHandle = e.type === clickEventName | ||
| || (e.type === 'keydown' && (e.key === 'Enter' || e.key === ' ')); | ||
|
|
||
| if (!shouldHandle) { | ||
| return; | ||
| } | ||
|
|
||
| const field: any = $(e.currentTarget).data('field'); | ||
| const isHeaderFilter = $(e.target).hasClass(CLASSES.headerFilter); | ||
|
|
||
| if (isHeaderFilter) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether we should do this. Suggestions?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot has indicated a valid problem, but I don't think that we need to fix it as it suggested.
The problem is that headerFilterMixin._applyColumnState adds several aria-attrs: label, haspopup, role. However we don't need them and we have to remove all of them from header filter icon.
Using headerFilterMixin._applyColumnState to add these attr, so that later they would be removed in the overriden _applyColumnState seems like bad design for me.
I suggest to remove usage of headerFilterMixin, and replace this _applyColumnState with a new function that would render headerFilter icon.