PanelPlugin: Allow inverting hideFromDefaults (#100473)
This commit is contained in:
@@ -55,7 +55,7 @@ export function createFieldConfigRegistry<TFieldConfigOptions>(
|
||||
const customDefault = config.standardOptions[id]?.defaultValue;
|
||||
const customSettings = config.standardOptions[id]?.settings;
|
||||
|
||||
if (customHideFromDefaults) {
|
||||
if (customHideFromDefaults !== undefined) {
|
||||
fieldConfigProp = {
|
||||
...fieldConfigProp,
|
||||
hideFromDefaults: customHideFromDefaults,
|
||||
|
||||
@@ -143,6 +143,29 @@ describe('OptionsPaneOptions', () => {
|
||||
expect(screen.queryByLabelText(OptionsPaneSelector.fieldLabel('TestPanel HiddenFromDef'))).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render options that are specifically not marked as hidden from defaults', () => {
|
||||
const scenario = new OptionsPaneOptionsTestScenario();
|
||||
|
||||
scenario.plugin = getPanelPlugin({
|
||||
id: 'TestPanel',
|
||||
}).useFieldConfig({
|
||||
standardOptions: {},
|
||||
useCustomConfig: (b) => {
|
||||
b.addBooleanSwitch({
|
||||
name: 'CustomBool',
|
||||
path: 'CustomBool',
|
||||
}).addBooleanSwitch({
|
||||
name: 'HiddenFromDef',
|
||||
path: 'HiddenFromDef',
|
||||
hideFromDefaults: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
scenario.render();
|
||||
expect(screen.queryByLabelText(OptionsPaneSelector.fieldLabel('TestPanel HiddenFromDef'))).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should create categories for field options with category', () => {
|
||||
const scenario = new OptionsPaneOptionsTestScenario();
|
||||
scenario.render();
|
||||
|
||||
Reference in New Issue
Block a user