-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add new props to feature flag props #17239
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -29,17 +29,37 @@ const FeatureFlagContext = createContext(GlobalFeatureFlags); | |||||||
* along with the current `FeatureFlagContext` to provide consumers to check if | ||||||||
* a feature flag is enabled or disabled in a given React tree | ||||||||
*/ | ||||||||
function FeatureFlags({ children, flags = {} }) { | ||||||||
function FeatureFlags({ | ||||||||
children, | ||||||||
flags = {}, | ||||||||
enableUseControlledStateWithValue, | ||||||||
enableV12TileDefaultIcons, | ||||||||
enableV12TileRadioIcons, | ||||||||
enableV12Overflowmenu, | ||||||||
enableTreeviewControllable, | ||||||||
enableExperimentalFocusWrapWithoutSentinels, | ||||||||
}) { | ||||||||
const parentScope = useContext(FeatureFlagContext); | ||||||||
const [prevParentScope, setPrevParentScope] = useState(parentScope); | ||||||||
|
||||||||
const combinedFlags = { | ||||||||
'enable-use-controlled-state-with-value': enableUseControlledStateWithValue, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like this is actually used anywhere anymore, is that what you see as well? The useControlledStateWithValue in here doesn't seem to be used anywhere either carbon/packages/react/src/internal/FeatureFlags.js Lines 49 to 51 in 36685a0
If so we should remove this one |
||||||||
'enable-v12-tile-default-icons': enableV12TileDefaultIcons, | ||||||||
'enable-v12-tile-radio-icons': enableV12TileRadioIcons, | ||||||||
'enable-v12-overflowmenu': enableV12Overflowmenu, | ||||||||
'enable-treeview-controllable': enableTreeviewControllable, | ||||||||
'enable-experimental-focus-wrap-without-sentinels': | ||||||||
enableExperimentalFocusWrapWithoutSentinels, | ||||||||
...flags, | ||||||||
}; | ||||||||
const [scope, updateScope] = useState(() => { | ||||||||
const scope = createScope(flags); | ||||||||
const scope = createScope(combinedFlags); | ||||||||
scope.mergeWithScope(parentScope); | ||||||||
return scope; | ||||||||
}); | ||||||||
|
||||||||
if (parentScope !== prevParentScope) { | ||||||||
const scope = createScope(flags); | ||||||||
const scope = createScope(combinedFlags); | ||||||||
scope.mergeWithScope(parentScope); | ||||||||
updateScope(scope); | ||||||||
setPrevParentScope(parentScope); | ||||||||
|
@@ -48,7 +68,7 @@ function FeatureFlags({ children, flags = {} }) { | |||||||
// We use a custom hook to detect if any of the keys or their values change | ||||||||
// for flags that are passed in. If they have changed, then we re-create the | ||||||||
// FeatureFlagScope using the new flags | ||||||||
useChangedValue(flags, isEqual, (changedFlags) => { | ||||||||
useChangedValue(combinedFlags, isEqual, (changedFlags) => { | ||||||||
const scope = createScope(changedFlags); | ||||||||
scope.mergeWithScope(parentScope); | ||||||||
updateScope(scope); | ||||||||
|
@@ -68,6 +88,12 @@ FeatureFlags.propTypes = { | |||||||
* Provide the feature flags to enabled or disabled in the current React tree | ||||||||
*/ | ||||||||
flags: PropTypes.objectOf(PropTypes.bool), | ||||||||
enableUseControlledStateWithValue: PropTypes.bool, | ||||||||
enableV12TileDefaultIcons: PropTypes.bool, | ||||||||
enableV12TileRadioIcons: PropTypes.bool, | ||||||||
enableV12Overflowmenu: PropTypes.bool, | ||||||||
enableTreeviewControllable: PropTypes.bool, | ||||||||
enableExperimentalFocusWrapWithoutSentinels: PropTypes.bool, | ||||||||
}; | ||||||||
|
||||||||
/** | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these need the same defaults as what's defined in the root flag definition?
carbon/packages/feature-flags/feature-flags.yml
Lines 25 to 52 in b9abee7