removed metadata_modal feature flag and related references to it#5965
Conversation
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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]); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
juliawu
left a comment
There was a problem hiding this comment.
Thanks for the cleanup! Just a minor comment
|
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 |
…e-metadata-modal-feature-flag
|
I ended up re-adding all of the actual feature flags due to the failing test case Once these changes make it to prod, we can remove all of the lingering metadata_modal feature flags |
…le/website into remove-metadata-modal-feature-flag
…e-metadata-modal-feature-flag
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
FacetSelectorSimplecomponentTesting
Verified locally by comparing local web component builds against the current production script.
Todo
Remove
metadata_modalfeature flag from all environments once the changes from this PR make it to prodBefore:
After: