apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.06k stars 13.61k forks source link

DRILL_TO_DETAIL #29491

Closed 1sarah closed 2 months ago

1sarah commented 3 months ago

Bug description

Drill to detail doesn't apply filters when using jinja tempating

How to reproduce the bug

Embedded dashboard

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 3 months ago

Hi @1sarah! I'm a bot designed to help you with bugs, questions, and contributions. I'm here to assist you while waiting for a human maintainer.

To resolve the issue where the "Drill to Detail" feature in Superset does not apply filters correctly when using Jinja templating, ensure that the filters are correctly passed and applied in the DrillDetailMenuItems component.

Here is a key part of the code that handles the filters:

const openModal = useCallback(
  (filters, event) => {
    onClick(event);
    onSelection();
    setFilters(filters);
    setShowModal(true);
  },
  [onClick, onSelection],
);

This function is responsible for opening the modal and setting the filters. Ensure that the filters are correctly formatted and passed to this function.

Additionally, the filters are mapped and displayed in the submenu:

const drillToDetailByMenuItem = drillByDisabled ? (
  <DisabledMenuItem {...props} key="drill-to-detail-by-disabled">
    {DRILL_TO_DETAIL_BY}
    <MenuItemTooltip title={drillByDisabled} />
  </DisabledMenuItem>
) : (
  <Menu.SubMenu
    {...props}
    popupOffset={[0, submenuYOffset]}
    popupClassName="chart-context-submenu"
    title={DRILL_TO_DETAIL_BY}
  >
    <div data-test="drill-to-detail-by-submenu">
      {filters.map((filter, i) => (
        <MenuItemWithTruncation
          {...props}
          tooltipText={`${DRILL_TO_DETAIL_BY} ${filter.formattedVal}`}
          key={`drill-detail-filter-${i}`}
          onClick={openModal.bind(null, [filter])}
        >
          {`${DRILL_TO_DETAIL_BY} `}
          <StyledFilter stripHTML>{filter.formattedVal}</StyledFilter>
        </MenuItemWithTruncation>
      ))}
      {filters.length > 1 && (
        <Menu.Item
          {...props}
          key="drill-detail-filter-all"
          onClick={openModal.bind(null, filters)}
        >
          <div>
            {`${DRILL_TO_DETAIL_BY} `}
            <StyledFilter stripHTML={false}>{t('all')}</StyledFilter>
          </div>
        </Menu.Item>
      )}
    </div>
  </Menu.SubMenu>
);

Ensure that the filters are correctly formatted and passed to the openModal function when a menu item is clicked. If the filters are not being applied correctly, check the format and content of the filters array being passed to the openModal function.

If the issue persists, you may need to debug the filters array to ensure it contains the correct values and is being passed correctly to the modal [1].

To continue talking to Dosu, mention @dosu.

rusackas commented 2 months ago

Thank you, but I'll close this (as a duplicate) in favor of https://github.com/apache/superset/issues/27396.