kgabryje commented on a change in pull request #15063:
URL: https://github.com/apache/superset/pull/15063#discussion_r649851737
##########
File path:
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -80,11 +80,31 @@ const FilterControls: FC<FilterControlsProps> = ({
element => element.type === TAB_TYPE,
);
const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
- if (!lastFocusedTabId || !dashboardHasTabs) {
+
+ // we check native filters scopes only on dashboards with tabs
+ if (!dashboardHasTabs) {
filtersInScope = cascadeFilters;
} else {
cascadeFilters.forEach((filter, index) => {
- if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+ // Filter is in scope if any of it's charts is visible.
+ // Chart is visible if it's placed in an active tab tree or if it's not
attached to any tab.
+ // Chart is in an active tab tree if all of it's ancestors of type TAB
are active
+ const isFilterInScope = cascadeFilters[index].chartsInScope?.some(
Review comment:
Riiiight 🤦 Done
##########
File path:
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -80,11 +80,31 @@ const FilterControls: FC<FilterControlsProps> = ({
element => element.type === TAB_TYPE,
);
const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
- if (!lastFocusedTabId || !dashboardHasTabs) {
+
+ // we check native filters scopes only on dashboards with tabs
+ if (!dashboardHasTabs) {
filtersInScope = cascadeFilters;
} else {
cascadeFilters.forEach((filter, index) => {
- if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+ // Filter is in scope if any of it's charts is visible.
+ // Chart is visible if it's placed in an active tab tree or if it's not
attached to any tab.
+ // Chart is in an active tab tree if all of it's ancestors of type TAB
are active
+ const isFilterInScope = cascadeFilters[index].chartsInScope?.some(
+ chartId => {
+ const chartLayoutItem = Object.values(dashboardLayout).find(
+ layoutItem => layoutItem.meta?.chartId === chartId,
+ );
+ const tabParents = chartLayoutItem?.parents.filter(
+ (parent: string) => dashboardLayout[parent].type === TAB_TYPE,
+ );
+ return (
Review comment:
I split some of that logic and moved it to
`superset/superset-frontend/src/dashboard/components/nativeFilters/state.ts`
##########
File path:
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -80,11 +80,31 @@ const FilterControls: FC<FilterControlsProps> = ({
element => element.type === TAB_TYPE,
);
const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
- if (!lastFocusedTabId || !dashboardHasTabs) {
+
+ // we check native filters scopes only on dashboards with tabs
+ if (!dashboardHasTabs) {
filtersInScope = cascadeFilters;
} else {
cascadeFilters.forEach((filter, index) => {
- if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+ // Filter is in scope if any of it's charts is visible.
+ // Chart is visible if it's placed in an active tab tree or if it's not
attached to any tab.
+ // Chart is in an active tab tree if all of it's ancestors of type TAB
are active
+ const isFilterInScope = cascadeFilters[index].chartsInScope?.some(
+ chartId => {
+ const chartLayoutItem = Object.values(dashboardLayout).find(
+ layoutItem => layoutItem.meta?.chartId === chartId,
+ );
+ const tabParents = chartLayoutItem?.parents.filter(
+ (parent: string) => dashboardLayout[parent].type === TAB_TYPE,
+ );
+ return (
Review comment:
I split some of that logic and moved it to
`superset/superset-frontend/src/dashboard/components/nativeFilters/state.ts`,
but I'm not sure if that's exactly what you expected. Can you take another look?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]