decaporg / decaporg/decap-cms

Ability to get the same behavior as the hidden widget in a custom widget

Open
#1,998 5 comments 5 reactions 0 assignees View on GitHub
pinned
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Is your feature request related to a problem? Please describe.**
I would like to create a version of [my uuid widget](https://github.com/netlify/netlify-cms/issues/1407#issuecomment-448625518) that does not render a control or a preview, similar to the `hidden` widget. I need to use it in various nested settings where having a visible widget crowds up the screen too much.

However, it appears that the `hidden` widget achieves it hidden-ness by being special cased in various places:

* https://github.com/netlify/netlify-cms/blob/b1e490dce5dfaa7dceaf85d710275d67f5dae687/packages/netlify-cms-core/src/components/Editor/EditorControlPane/EditorControlPane.js#L55
* https://github.com/netlify/netlify-cms/blob/b1e490dce5dfaa7dceaf85d710275d67f5dae687/packages/netlify-cms-core/src/components/Editor/EditorControlPane/EditorControlPane.js#L27
* https://github.com/netlify/netlify-cms/blob/b1e490dce5dfaa7dceaf85d710275d67f5dae687/packages/netlify-cms-core/src/components/Editor/EditorPreviewPane/EditorPreview.js#L7
* https://github.com/netlify/netlify-cms/blob/b1e490dce5dfaa7dceaf85d710275d67f5dae687/packages/netlify-cms-core/src/components/Editor/EditorPreviewPane/EditorPreview.js#L7

... and a few more.

**Describe the solution you'd like**

That widgets can somehow opt into being hidden and receive the same treatment as the `hidden` widget.

(Although I guess that would mean that my hack to call `onChange` in `componentDidMount` wouldn't work, but hopefully we can find a way to avoid that :)

**Describe alternatives you've considered**

To just live with all those id fields being visible in my editor components.
Alternatively to use the `hidden` widget with a default function (suggested in https://github.com/netlify/netlify-cms/issues/1407), but for my use case that's presently blocked by something like https://github.com/netlify/netlify-cms/pull/1662 as default values for nested fields don't seem to work at all right now.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.