Skip to content

GridCore: add methods to HeaderPanel to add/remove toolbar items#33118

Open
anna-shakhova wants to merge 6 commits intoDevExpress:26_1from
anna-shakhova:26_1__header_panel_add_remove_item
Open

GridCore: add methods to HeaderPanel to add/remove toolbar items#33118
anna-shakhova wants to merge 6 commits intoDevExpress:26_1from
anna-shakhova:26_1__header_panel_add_remove_item

Conversation

@anna-shakhova
Copy link
Copy Markdown
Contributor

No description provided.

@anna-shakhova anna-shakhova self-assigned this Apr 1, 2026
@anna-shakhova anna-shakhova reopened this Apr 1, 2026
@anna-shakhova anna-shakhova force-pushed the 26_1__header_panel_add_remove_item branch from 324e84d to a88207d Compare April 1, 2026 12:57
@anna-shakhova anna-shakhova force-pushed the 26_1__header_panel_add_remove_item branch from a88207d to e6e56e6 Compare April 1, 2026 14:15
@anna-shakhova anna-shakhova reopened this Apr 2, 2026
@anna-shakhova anna-shakhova marked this pull request as ready for review April 2, 2026 10:22
@anna-shakhova anna-shakhova requested a review from a team as a code owner April 2, 2026 10:22
Copilot AI review requested due to automatic review settings April 2, 2026 10:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a mechanism for dynamically managing GridCore header panel toolbar items by adding explicit addToolbarItem / removeToolbarItem APIs on HeaderPanel, and refactors the search panel integration to use these APIs (via a new controller) instead of extending HeaderPanel directly.

Changes:

  • Added HeaderPanel.addToolbarItem() / removeToolbarItem() with centralized sorting by sortIndex.
  • Refactored the search panel toolbar integration into SearchPanelViewController that registers/unregisters the search toolbar item on option changes.
  • Updated/added tests (QUnit + Jest integration) and adjusted related typing for toolbar items.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/keyboardNavigation.keyboardKeys.tests.js Adjusts test setup ordering for searchPanel options before module initialization.
packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/headerPanel.tests.js Switches tests to use this.option('searchPanel', ...) instead of mutating this.options.searchPanel.
packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/gridView.tests.js Refactors one test’s grid creation/render flow; currently includes a stray debugger.
packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/dataGrid.tests.js Removes an assertion that toolbar recomputation happens on searchPanel option changes.
packages/devextreme/js/__internal/grids/new/grid_core/toolbar/utils.ts Formatting-only change to the types import.
packages/devextreme/js/__internal/grids/new/grid_core/toolbar/types.ts Extends toolbar item typing with sortIndex and onItemRendered.
packages/devextreme/js/__internal/grids/grid_core/search/m_search.ts Introduces SearchPanelViewController and registers/unregisters the search toolbar item dynamically.
packages/devextreme/js/__internal/grids/grid_core/search/tests/m_search.integration.test.ts New Jest integration tests covering searchPanel runtime option changes without headerPanel invalidation.
packages/devextreme/js/__internal/grids/grid_core/m_types.ts Adds searchPanel to the controllers typing map.
packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts Routes Ctrl+F focus behavior through the new searchPanel controller.
packages/devextreme/js/__internal/grids/grid_core/header_panel/m_header_panel.ts Implements toolbar item registry + sorting, and wires onItemRendered passthrough.
packages/devextreme/js/__internal/grids/grid_core/header_panel/tests/m_header_panel.integration.test.ts New Jest integration tests for the new headerPanel toolbar item registry APIs.
packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts Updates typing of headerPanel toolbar items to the shared ToolbarItem type.
packages/devextreme/js/__internal/grids/data_grid/export/m_export.ts Removes local sort helper, relying on headerPanel’s centralized sorting.

@anna-shakhova anna-shakhova force-pushed the 26_1__header_panel_add_remove_item branch from 06979b3 to 39dc044 Compare April 2, 2026 12:20
Copilot AI review requested due to automatic review settings April 3, 2026 09:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/devextreme/js/__internal/grids/grid_core/search/m_search.ts:165

  • SearchPanelViewController.optionChanged only reacts to searchPanel.text and searchPanel.visible, but it marks all searchPanel* changes as handled. This breaks common update paths like option('searchPanel', { visible: true, ... }) (fullName === 'searchPanel') because the controller won't register/unregister the toolbar item, so the search panel never appears/disappears. It also prevents runtime updates to placeholder/width when visible. Consider handling fullName === 'searchPanel' (and other relevant searchPanel.* options) by updating/re-registering the toolbar item and/or updating the existing TextBox instance when already visible.
  public optionChanged(args: OptionChanged): void {
    if (args.name === 'searchPanel') {
      if (args.fullName === 'searchPanel.text') {
        const editor = this.getSearchTextEditor();
        if (editor) {
          editor.option('value', args.value);
        }
      }

      if (args.fullName === 'searchPanel.visible') {
        this._updateSearchPanelItem();
      }

      args.handled = true;
    } else {

Comment on lines +45 to +46
this._registeredToolbarItems.set(name, item);

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addToolbarItem(name, item) stores the item under the provided name, but does not ensure item.name matches (or is set at all). This can break downstream logic that relies on item.name (e.g., setToolbarItemDisabled searches by item.name) and also makes toolbar.items overrides by name ambiguous. Consider normalizing inside addToolbarItem (e.g., set item.name ??= name, or validate/mismatch warning) so callers don't have to duplicate the name in two places.

Suggested change
this._registeredToolbarItems.set(name, item);
const normalizedItem = {
...item,
name,
};
this._registeredToolbarItems.set(name, normalizedItem);

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 3, 2026 09:56
@anna-shakhova anna-shakhova force-pushed the 26_1__header_panel_add_remove_item branch from f6f7cd9 to a437a97 Compare April 3, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants