Skip to content

Commit 1fd9c1f

Browse files
fix: check supportMotion before returning NONE in styleReady
When motionName is not provided, styleReady should not return NONE even if motionAppear is true, to allow content to render immediately. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent fb7b514 commit 1fd9c1f

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/hooks/useStatus.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,13 @@ export default function useStatus(
312312
mergedStyle,
313313
asyncVisible ?? visible,
314314

315-
!mountedRef.current && currentStatus === STATUS_NONE && motionAppear
316-
? // Appear
317-
'NONE'
318-
: // Enter or Leave
315+
// Appear Check
316+
!mountedRef.current &&
317+
currentStatus === STATUS_NONE &&
318+
supportMotion &&
319+
motionAppear
320+
? 'NONE'
321+
: // Enter or Leave check
319322
step === STEP_START || step === STEP_ACTIVE
320323
? styleStep === step
321324
: true,

tests/CSSMotion.spec.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,26 @@ describe('CSSMotion', () => {
510510
);
511511
});
512512

513+
it('renders content on first mount when motionName is not provided but motionAppear is true', () => {
514+
const mockRender = jest.fn(() => <div>content</div>) as jest.Mock;
515+
(mockRender as any).mock.calls = [] as any;
516+
517+
render(
518+
<CSSMotion visible motionAppear>
519+
{mockRender}
520+
</CSSMotion>,
521+
);
522+
523+
// When motionName is not provided, styleReady should not be 'NONE',
524+
// so content should render immediately
525+
expect(mockRender).toHaveBeenCalled();
526+
expect(mockRender.mock.calls[0][0]).toEqual(
527+
expect.objectContaining({
528+
visible: true,
529+
}),
530+
);
531+
});
532+
513533
describe('immediately', () => {
514534
it('motionLeaveImmediately', async () => {
515535
const { container } = render(

0 commit comments

Comments
 (0)