Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Pass `contained` to scroll inside a fixed-height parent. The wrapper must have a

## SSR Behavior

- Container divs are always rendered (hidden with `display: none` until initialized)
- Container divs are always rendered and remain measurable while loading
- No `isClient` state or extra rerender — containers exist from first render
- SuperDoc initializes in `useEffect` (client-side only) and mounts into the existing containers
- `renderLoading()` shown alongside hidden containers until initialization completes
Expand Down
12 changes: 12 additions & 0 deletions packages/react/src/SuperDocEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ describe('SuperDocEditor', () => {

expect(container.querySelector('[data-testid="loading"]')).toBeTruthy();
});

it('keeps the editor container measurable while loading', () => {
const { container } = render(
<SuperDocEditor renderLoading={() => <div data-testid='loading'>Loading...</div>} />,
);

const editorContainer = container.querySelector('.superdoc-editor-container') as HTMLElement;

expect(editorContainer.style.display).not.toBe('none');
expect(editorContainer.style.visibility).toBe('hidden');
expect(editorContainer.style.pointerEvents).toBe('none');
});
});

describe('callbacks', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/SuperDocEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ function SuperDocEditorInner(props: SuperDocEditorProps, ref: ForwardedRef<Super
}, [documentProp, user, users, modules, role, hideToolbar, contained, containerId, toolbarId]);

const wrapperClassName = ['superdoc-wrapper', className].filter(Boolean).join(' ');
const hideWhenLoading: CSSProperties | undefined = isLoading ? { display: 'none' } : undefined;
const hideWhenLoading: CSSProperties | undefined = isLoading
? { visibility: 'hidden', pointerEvents: 'none' }
: undefined;
Comment thread
palmer-cl marked this conversation as resolved.

const wrapperStyle: CSSProperties = {
...style,
Expand Down
Loading