[AnalyticalTable]: Column filter popover closes on every selection with a popup-based custom Filter (e.g. MultiComboBox)

Offen Anfängerfreundlich
#9,181 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
react, typescript
Bereich
frontend

Rechercherichtung

Beginne in packages/main/src/components/AnalyticalTable/defaults/Column/ColumnHeaderModal.tsx, wo der Issue den item-click-Handler und das bedingungslose setOpen(false) nennt. Prüfe, wie sich Klicks auf die Filterzeile von Sortier-, Gruppierungs- und Einfrieren-Aktionen unterscheiden, und reproduziere das Problem mit einem benutzerdefinierten popup-basierten Filter wie MultiComboBox. Als erledigt gilt die Änderung, wenn die Auswahl von Filterwerten das Header-Popover geöffnet lässt, während explizite Aktionen es weiterhin schließen können; im Payload wird keine Testdatei genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

When a column uses a custom Filter that is a popup-based control (MultiComboBox, Select, ComboBox, DatePicker, …), the column-header popover closes on every selection. For a MultiComboBox this makes multi-selection practically unusable: the popover disappears after each picked item, so the user has to re-open it for every value.

Typing into the control does not close the popover — only selecting a value from its dropdown does.

Reproduction steps

  1. Render an AnalyticalTable with filterable and a column whose Filter render-prop returns a MultiComboBox (with MultiComboBoxItem children) and calls column.setFilter(...) in onSelectionChange.
  2. Open the column header → Filter.
  3. Open the MultiComboBox dropdown and select an item.
  4. The column-header popover closes immediately.

Expected Behaviour

Selecting a value in a custom filter control should not close the column-header popover — at least not for multi-value controls. The popover should stay open so the user can pick multiple values, and close only on Escape, an outside click, or an explicit sort/group/freeze action.

Root cause

The popover is not closed by the ui5-popover's own light-dismiss — it is unmounted by React. In packages/main/src/components/AnalyticalTable/defaults/Column/ColumnHeaderModal.tsx, the List's item-click handler ends with an unconditional setOpen(false):

const handleModalItemClick = (e) => {
  // ...sort / group / freeze branches, each keyed off e.detail.item.dataset...
  setOpen(false); // ColumnHeaderModal.tsx:130 — runs for the filter row too
};

setOpen is the header cell's setPopoverOpen. The custom filter is rendered inside a clickable ListItemCustom (type="Active"), so selecting a value in the filter control surfaces an item-click on the filter row (which carries no data-sort / data-modal-item). The switch has no matching case, so execution falls through to the unconditional setOpen(false), which flips popoverOpen to false and unmounts the popover.

Because it is a React unmount rather than a native popover close, there is no before-close/close event — so onBeforeClose / modal cannot be used to prevent it.

Suggested fix

Skip setOpen(false) in handleModalItemClick when the clicked row is the filter row (no data-sort / data-modal-item), or render the filter's ListItemCustom as non-interactive. Either removes the need for any consumer workaround and fixes it for all popup-based custom filters.

Consumer workaround (until fixed)

Cancel the item-click for the filter row in the capture phase, using the popoverRef from the Filter render-prop:

const DepartmentFilter = ({ column, popoverRef }: ColumnFilterProps) => {
  useEffect(() => {
    const popover = popoverRef.current;
    if (!popover) {
      return;
    }
    const keepOpenOnFilterClick = (e: Event) => {
      const item = (e as CustomEvent<{ item?: HTMLElement }>).detail?.item;
      // filter row has no data-sort / data-modal-item marker
      if (item && !item.dataset.sort && !item.dataset.modalItem) {
        e.stopImmediatePropagation();
      }
    };
    popover.addEventListener('item-click', keepOpenOnFilterClick, true);
    return () => popover.removeEventListener('item-click', keepOpenOnFilterClick, true);
  }, [popoverRef]);

  // ...MultiComboBox with onSelectionChange -> column.setFilter(...)
};

Environment Info

  • UI5 Web Components for React Version: 2.29.0
  • UI5 Web Components Version: 2.29.0
  • Browser: Chrome
  • Operating System: macOS

Additional Context

Not specific to MultiComboBox — the same code path closes the popover for any popup-based custom filter (Select, ComboBox, DatePicker, …). It is simply most disruptive for MultiComboBox, where selecting multiple values in a row is the intended interaction. A plain text Input filter is unaffected (it has no dropdown to select from, so no item-click is fired).

Vorherrschende Sprache
TypeScript
Sterne
544
Forks
113
Ø Merge
1 T. 16 Std.
Gemergte PRs (30 T.)
34

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus UI5/webcomponents-react

Alle Issues in UI5/webcomponents-react

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.