Skip to content

fix: multiple reloads in timeline#479

Merged
contentstackMridul merged 4 commits intodevelop_v3from
VE_6673
Aug 5, 2025
Merged

fix: multiple reloads in timeline#479
contentstackMridul merged 4 commits intodevelop_v3from
VE_6673

Conversation

@contentstackMridul
Copy link
Copy Markdown
Contributor

fix: multiple reloads in timeline
Ticket -> https://contentstack.atlassian.net/browse/VE-6673
Test Report ->
Screenshot 2025-07-11 at 16 43 01

This pull request introduces enhancements to the live preview functionality, focusing on improving query parameter handling, adding support for timeline-specific behavior, and refining event listener logic. The most important changes include updates to query parameter management, adjustments to event handling, and integration of timeline-specific checks.

Query Parameter Handling Enhancements:

  • src/utils/addLivePreviewQueryTags.ts: Added support for the preview_timestamp query parameter and refined logic for adding live_preview, content_type_uid, and entry_uid query parameters.
  • src/utils/index.ts: Improved handling of click events by ensuring query parameters are added only to valid anchor elements and their descendants.

Timeline-Specific Behavior:

Event Listener Refinements:

@contentstackMridul contentstackMridul requested a review from a team as a code owner August 5, 2025 07:02
@contentstackMridul contentstackMridul changed the base branch from main to develop_v3 August 5, 2025 07:06
Comment thread src/utils/index.ts
const target: any = event.target;
const targetHref: string | any = target.href;
const clickedElement = event.target;
const anchorElement = clickedElement.closest('a');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@contentstackMridul Have we checked what happens when the clickedElement is itself an anchor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if the clicked element is itself a anchor element, the .closest method will return the clicked element and it will not traverse the DOM up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added test for the same

Comment thread src/utils/index.ts
const anchorElement = clickedElement.closest('a');

// Only proceed if the clicked element is either an anchor or a direct/indirect child of an anchor
if (!anchorElement || !anchorElement.contains(clickedElement)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what if the anchorElement is same as the clickedElement? @contentstackMridul

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if the clicked element is itself a anchor element, the .closest method will return the clicked element and it will not traverse the DOM up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added test for the same

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 5, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.15% 9098 / 12609
🔵 Statements 72.15% 9098 / 12609
🔵 Functions 71.86% 327 / 455
🔵 Branches 84.3% 1144 / 1357
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/livePreview/eventManager/postMessageEvent.hooks.ts 83.69% 76.47% 75% 83.69% 34-36, 83-84, 97, 106, 119-127
src/utils/addLivePreviewQueryTags.ts 74.07% 50% 100% 74.07% 13-14, 16-18, 20-21
src/utils/index.ts 89.74% 85.71% 100% 89.74% 36-37, 45-46
Generated in workflow #497 for commit e781891 by the Vitest Coverage Report Action

Copy link
Copy Markdown

@KANE-99 KANE-99 left a comment

Choose a reason for hiding this comment

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

LGTM

@contentstackMridul contentstackMridul merged commit 7682fc4 into develop_v3 Aug 5, 2025
9 of 11 checks passed
@contentstackMridul contentstackMridul deleted the VE_6673 branch August 5, 2025 12:05
@contentstackMridul contentstackMridul restored the VE_6673 branch August 6, 2025 06:38
@faraazb faraazb deleted the VE_6673 branch August 6, 2025 08:39
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