Skip to content

removed metadata_modal feature flag and related references to it#5965

Merged
dwnoble merged 10 commits intodatacommonsorg:masterfrom
dwnoble:remove-metadata-modal-feature-flag
Feb 6, 2026
Merged

removed metadata_modal feature flag and related references to it#5965
dwnoble merged 10 commits intodatacommonsorg:masterfrom
dwnoble:remove-metadata-modal-feature-flag

Conversation

@dwnoble
Copy link
Contributor

@dwnoble dwnoble commented Feb 4, 2026

Effectively removed the feature flag for the 'new' metadata modal, as the feature is now fully launched across all environments. Removing the flag ensures that web components, which were previously defaulting to the old modal view, now correctly display the updated metadata modal and references.

Key Changes

  • Removed the code logic governing the metadata modal feature flag.
  • Removed now-unused FacetSelectorSimple component
  • Verified fix locally

Testing
Verified locally by comparing local web component builds against the current production script.

Todo
Remove metadata_modal feature flag from all environments once the changes from this PR make it to prod

Before:

4n8oxZdautiNkxk
<html>

<head>
  <script src="https://datacommons.org/datacommons.js"></script>
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=block" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined&display=block">
</head>

<body style="max-width: 80vw; margin: auto">
  <datacommons-bar header="Population" variables="Count_Person" places="country/USA country/IND country/MEX">
  </datacommons-bar>
</body>

</html>

After:

4FAK58as9PfVhuk
<html>

<head>
  <script src="http://localhost:8080/datacommons.js"></script>
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=block" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined&display=block">
</head>
<body style="max-width: 80vw; margin: auto">
  <datacommons-bar header="Population" variables="Count_Person" places="country/USA country/IND country/MEX">
  </datacommons-bar>
</body>
</html>

@dwnoble dwnoble requested review from juliawu, miss-o-soup and nick-next and removed request for nick-next February 4, 2026 23:56
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dwnoble, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the application by fully deprecating and removing the metadata_modal feature flag. With the new metadata modal now universally launched, the conditional logic and the older "simple" facet selector component are no longer necessary. The FacetSelector component has been refactored to directly incorporate the advanced modal functionality, simplifying the architecture and ensuring a consistent, updated user experience across all environments, particularly for web components.

Highlights

  • Feature Flag Removal: The 'metadata_modal' feature flag has been completely removed from the codebase and all environment-specific configuration files, as the new metadata modal is now fully launched.
  • Consolidated Facet Selector: The FacetSelector component has been refactored to directly implement the advanced metadata modal logic, eliminating the need for a feature flag to switch between 'rich' and 'simple' versions.
  • Deprecated Components Removed: The FacetSelectorRich and FacetSelectorSimple components, previously used for conditional rendering based on the feature flag, have been deleted, simplifying the codebase.
  • Web Component Consistency: This change ensures that web components consistently display the updated metadata modal, resolving previous instances where they might have defaulted to the old modal view.
Changelog
  • docs/feature_flags.md
    • Updated documentation to remove references to the metadata_modal feature flag, replacing it with page_overview_ga in an example.
  • server/config/feature_flag_configs/autopush.json
    • The metadata_modal feature flag entry has been removed.
  • server/config/feature_flag_configs/custom.json
    • The metadata_modal feature flag entry has been removed.
  • server/config/feature_flag_configs/dev.json
    • The metadata_modal feature flag entry has been removed.
  • server/config/feature_flag_configs/local.json
    • The metadata_modal feature flag entry has been removed.
  • server/config/feature_flag_configs/staging.json
    • The metadata_modal feature flag entry has been removed.
  • static/js/components/subject_page/block.tsx
    • Removed the import of METADATA_FEATURE_FLAG and its conditional usage when determining facet selector eligibility.
  • static/js/components/tiles/chart_footer.tsx
    • Removed the import of METADATA_FEATURE_FLAG and its conditional usage for displaying the API button.
  • static/js/shared/facet_selector/facet_option_content.tsx
    • Updated the import path for SELECTOR_PREFIX from facet_selector_rich to facet_selector.
  • static/js/shared/facet_selector/facet_selector.tsx
    • This file was significantly refactored to directly contain the logic previously found in FacetSelectorRich, becoming the single, unified facet selector component.
    • Imports for FacetSelectorRich and FacetSelectorSimple were removed, and new imports for UI components and utility functions were added.
  • static/js/shared/facet_selector/facet_selector_grouped_content.tsx
    • Updated the import path for SELECTOR_PREFIX from facet_selector_rich to facet_selector.
  • static/js/shared/facet_selector/facet_selector_rich.tsx
    • This file has been deleted, as its functionality was merged into facet_selector.tsx.
  • static/js/shared/facet_selector/facet_selector_simple.tsx
    • This file has been deleted, as the "simple" metadata modal is no longer supported.
  • static/js/shared/feature_flags/util.ts
    • The METADATA_FEATURE_FLAG constant has been removed.
    • An example URL in the comments was updated to reflect the removal of metadata_modal.
  • static/js/shared/util.ts
    • Updated the import path for FacetSelectorFacetInfo from facet_selector_rich to facet_selector.
  • static/js/tools/shared/metadata/tile_sources.tsx
    • Removed the import of METADATA_FEATURE_FLAG and its conditional usage for rendering the TileMetadataModal.
Activity
  • The author, dwnoble, initiated this pull request to remove an obsolete feature flag.
  • Local verification was performed by comparing web component builds against the current production script to ensure the fix.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively removes the metadata_modal feature flag and cleans up the related code, including deleting the FacetSelectorSimple component and merging FacetSelectorRich into FacetSelector. The changes are logical and follow the PR's description. I've identified a couple of potential issues in the refactored FacetSelector component: one related to an incomplete useEffect dependency array which could cause bugs, and another related to an unsafe function call that could lead to a runtime error. Addressing these will improve the robustness of the component.

Comment on lines +353 to +365
useEffect(() => {
const injectedFacetId = useInjectedFacet
? findMatchingFacets(facetList[0]["metadataMap"], props?.facetSelector)
: undefined;
if (!_.isEmpty(injectedFacetId)) {
setModalSelections({ [facetList[0]["dcid"]]: injectedFacetId[0] });
}
// If modal is closed without updating facets, we want to reset the
// selections in the modal.
if (!open && !useInjectedFacet) {
setModalSelections(svFacetId);
}
}, [svFacetId, open]);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The dependency array for this useEffect hook is incomplete. It uses facetList, useInjectedFacet, and props.facetSelector, but they are not included in the array. This violates the rules of hooks and can lead to stale closures and bugs where the effect doesn't re-run with the latest values.

Additionally, there's a potentially unsafe access to facetList[0]. While the parent component seems to ensure facetList is not empty, adding a guard here would make the component more robust.

I've suggested a fix that adds the missing dependencies and includes a check for facetList.

  useEffect(() => {
    if (useInjectedFacet && facetList && facetList.length > 0) {
      const injectedFacetId = findMatchingFacets(
        facetList[0]["metadataMap"],
        props.facetSelector
      );
      if (!_.isEmpty(injectedFacetId)) {
        setModalSelections({ [facetList[0]["dcid"]]: injectedFacetId[0] });
      }
    }
    // If modal is closed without updating facets, we want to reset the
    // selections in the modal.
    if (!open && !useInjectedFacet) {
      setModalSelections(svFacetId);
    }
  }, [svFacetId, open, facetList, useInjectedFacet, props.facetSelector]);

}
});
onSvFacetIdUpdated(modalSelections, metadataMap);
props.setUseInjectedFacet(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The setUseInjectedFacet prop is defined as optional in FacetSelectorProps, so it could be undefined at runtime. Calling it directly without checking for its existence may cause a runtime error if the component is used without this prop being passed. Using optional chaining (?.) will safely call the function only if it exists.

    props.setUseInjectedFacet?.(false);

Copy link
Contributor

@juliawu juliawu left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup! Just a minor comment

@juliawu
Copy link
Contributor

juliawu commented Feb 5, 2026

Looks like the feature flag test is failing because it doesn't allow for leaving a lone feature flag on production. How about we go stepwise. Let's remove feature flag references and keep the FacetSelectorSimple removal \ FacetSelectorRich rename here, but make changes to the .jsons, along with the prod json in a separate PR?

@dwnoble
Copy link
Contributor Author

dwnoble commented Feb 5, 2026

I ended up re-adding all of the actual feature flags due to the failing test case test_load_feature_flag_files in server/tests/lib/util_test.py.

Once these changes make it to prod, we can remove all of the lingering metadata_modal feature flags

@dwnoble dwnoble merged commit 20192fb into datacommonsorg:master Feb 6, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants