Skip to content

Nt 2695 handle optimized entry children visibility during the sdk lifecycle#176

Merged
Lotfi Anwar L Arif (Lotfi-Arif) merged 12 commits intomainfrom
NT-2695-handle-optimized-entry-children-visibility-during-the-sdk-lifecycle
Mar 17, 2026
Merged

Nt 2695 handle optimized entry children visibility during the sdk lifecycle#176
Lotfi Anwar L Arif (Lotfi-Arif) merged 12 commits intomainfrom
NT-2695-handle-optimized-entry-children-visibility-during-the-sdk-lifecycle

Conversation

@Lotfi-Arif
Copy link
Copy Markdown
Contributor

@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) commented Mar 13, 2026

PR Summary

  • Enhanced Personalization to safely support consumer-provided content as either:
    • render-prop children ((resolvedEntry) => ReactNode)
    • direct React nodes/elements.
  • Added nesting protection to block OptimizedEntry/Personalization from being nested with the same baseline entry ID.
  • Kept wrapper layout-neutral with display: contents, while allowing semantic wrapper selection via as="div" | "span" (default div).
  • Added loading layout-target element (data-ctfl-loading-layout-target) so fallback UI remains styleable/targetable even when wrapper uses display: contents.
  • Updated lifecycle behavior to be inferred (removed static lifecycleMode API):
    • personalized entries render when canPersonalize === true
    • non-personalized entries render after SDK init state is ready
    • SSR path renders loading invisibly to preserve layout space.
  • Ensured tracking/event behavior does not interfere with host app propagation/default handling.
  • Refactored and split lifecycle tests, updated docs, and removed outdated spec-mode references.

- Update README with render-prop, wrapper element, and layout-neutral
  behavior details.
- Add nesting guard documentation and implementation to block nested
  Personalization with duplicate baseline entry IDs.
- Add lifecycle and nesting tests for Personalization component.
- Refine loading fallback and baseline personalizable logic.
Render a concrete element with `data-ctfl-loading-layout-target` during
loading,
ensuring layout and visibility remain targetable even when using
`display: contents`. Adds tests for block and inline wrapper cases.
- Introduce `lifecycleMode` prop for SPA and hybrid SSR-SPA rendering
- Render invisible loading target during SSR in hybrid mode
- Block nested wrappers with duplicate baseline entry IDs at runtime
- Update docs and tests for new lifecycle behavior
- Baseline content now renders invisibly during SSR or first hydration
  frame.
- Non-personalized entries are no longer gated behind sdkInitialized.
- Tests and documentation updated to reflect new readiness logic.
- Replace Personalization with OptimizedEntry throughout the codebase.
- Move shared logic to optimizedEntryUtils and useOptimizedEntryState.
- Update exports and types to match new component name.
- Update DefaultLoadingFallback to render provided children instead of
  hardcoded loading text.
- Adjust OptimizedEntry and related tests to display baseline content
  during loading.
- Refactor loading render state logic for clarity.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! It may be possible to further optimize OptimizedEntry and the utils it's based on to reduce some logic and duplication, but on the other hand, I like how explicit it is, and that may be more valuable at this stage.

@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) merged commit 4e2f557 into main Mar 17, 2026
29 checks passed
@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) deleted the NT-2695-handle-optimized-entry-children-visibility-during-the-sdk-lifecycle branch March 17, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants