Unlocking the Magic of Editable Fields in Hidden Components with Sitecore JSS
- Cristina Paolillo
- Dec 20, 2024
- 3 min read
Today, I am thrilled to share a breakthrough that has resolved one of the most frustrating challenges I've encountered while editing in Sitecore Pages. After countless hours of reverse engineering and experimentation, I found a way to reset the graphical components that Sitecore uses to make fields editable on Pages, even when those fields are initially hidden. The solution? A magical API called resetEditorChromes from the @sitecore-jss/sitecore-jss-nextjs/utils module.
Let me walk you through the problem, the journey to the solution, and the code that makes it all happen.
The Problem: Editing Hidden Fields in Radix Dialogs and Popovers
In our project, we had several components that used Radix UI's Dialog and Popover to display menus and modals. These components worked beautifully for end users but posed a significant challenge for content editors using Sitecore Pages.
Fields inside these modals and popovers were not editable directly from Pages. Editors were forced to switch to the Content Tree to make changes, breaking the seamless editing experience that Sitecore promises.
I scoured the Sitecore documentation for a way to reset the UI after an action (like opening a dialog), hoping to refresh the editing chrome for these hidden fields. Unfortunately, I found no solution.

The Breakthrough: Reverse Engineering
When documentation fails, reverse engineering often saves the day. By digging into the Sitecore JSS utilities, I discovered the resetEditorChromes function. This API does exactly what I needed: it refreshes the editor UI, making previously hidden fields editable within Pages.
Here is the code that makes the magic happen:
import * as Dialog from '@radix-ui/react-dialog';
...
import { resetEditorChromes } from '@sitecore-jss/sitecore-jss-nextjs/utils';
import { useIsPageEditing } from 'src/hooks/useIsPageEditing';
...
export const BillInformationDialog = ({ billInformationTitle, billItems }: BillInformationDialogProps) => {
const isPageEditing = useIsPageEditing();
return (
<Dialog.Root
onOpenChange={() => {
if (isPageEditing) {
setTimeout(() => {
resetEditorChromes();
}, 500);
}
}}
>
<DialogTrigger icon={ICONS.ARROW_UP} textField={billInformationTitle} className={styles.trigger} />
<DialogContent>
<DialogHeader headerTitle={billInformationTitle} />
<div className={styles.itemsWrapper}>
<InformationList billItems={billItems} />
</div>
</DialogContent>
</Dialog.Root>
);
};
The Solution Explained
The Key Functionality
The magic happens in the onOpenChange handler of the Dialog.Root component:
onOpenChange={() => {
if (isPageEditing) {
setTimeout(() => {
resetEditorChromes();
}, 500);
}
}}
useIsPageEditing: This custom hook determines if the page is in editing mode.
resetEditorChromes: This function refreshes the Sitecore editor's UI, enabling fields within the dialog to become editable.
setTimeout: A 500ms delay ensures that the dialog is fully rendered before the editor chrome reset is triggered.
Why This Works
When a field is hidden (e.g., inside a dialog or popover), Sitecore's editing UI doesn't render the necessary overlays. By resetting the editor chrome after the dialog opens, we force Sitecore to re-evaluate the DOM and render the overlays for the now-visible fields.
The Impact
This small but powerful change has completely transformed the editing experience for our content authors. No more switching to the Content Tree to edit fields inside modals. Everything can now be managed directly from Pages, as it should be.

Final Thoughts
This discovery underscores the importance of diving into the tools we use and understanding their inner workings. While official documentation is invaluable, sometimes the answers lie just beneath the surface, waiting to be uncovered.
If you face similar challenges in your Sitecore projects, give resetEditorChromes a try. And remember: reverse engineering is your friend!
Have you encountered similar issues or found other hidden gems in Sitecore JSS? Let me know in the comments below!
Commentaires