Skip to content

Fix deep linking for OBBBA household-by-household iframe#2702

Merged
MaxGhenis merged 6 commits into
masterfrom
MaxGhenis/issue2701
Jul 24, 2025
Merged

Fix deep linking for OBBBA household-by-household iframe#2702
MaxGhenis merged 6 commits into
masterfrom
MaxGhenis/issue2701

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • Implements URL parameter passing from parent app to embedded iframe on initial load
  • Adds postMessage listener to update parent app URL when iframe URL changes
  • Fixes deep linking issues for the OBBBA household-by-household analysis tool

Problem

The OBBBA household-by-household iframe had two main issues:

  1. Permalinks with query parameters (e.g., ?household=46067&baseline=tcja-expiration) were not being passed to the iframe
  2. Selecting a household in the OBBBA app did not update the parent app's URL

Solution

Modified AppPage.jsx to:

  • Construct iframe URLs that include query parameters from the parent app
  • Listen for postMessage events from the iframe to synchronize URL changes
  • Use memoization for performance optimization

Test plan

  • Navigate to /us/obbba-household-by-household?household=46067&baseline=tcja-expiration
  • Verify the iframe loads with the specified household selected
  • Select a different household in the iframe
  • Verify the parent app URL updates to reflect the new selection
  • Refresh the page and verify the selected household persists

Fixes #2701

🤖 Generated with Claude Code

- Pass URL parameters from parent app to embedded iframe on initial load
- Listen for postMessage events from iframe to update parent app URL
- Memoize iframe URL construction and origin verification for performance

This enables proper deep linking functionality where:
1. Permalinks with query parameters (e.g., ?household=46067&baseline=tcja-expiration) correctly load in the iframe
2. Household selections in the OBBBA app update the parent app's URL for shareable links

Fixes #2701

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2025 21:18
@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
policyengine-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 9:52pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes deep linking functionality for the OBBBA household-by-household iframe by enabling bi-directional URL synchronization between the parent app and embedded iframe.

  • Implements URL parameter forwarding from parent to iframe on initial load
  • Adds postMessage listener to update parent URL when iframe navigation occurs
  • Optimizes performance using React memoization for URL construction and origin validation

Comment thread src/pages/AppPage.jsx Outdated
MaxGhenis and others added 2 commits July 24, 2025 17:22
- Use localhost:3001 for OBBBA household-by-household app when running locally
- Remove unused OBBBAHouseholdExplorer component
- Update both iframe URL and origin verification to handle localhost

This allows developers to test the OBBBA integration locally without needing to deploy changes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Although currently unused, keeping this component for potential future use.
Both OBBBA apps currently use the generic AppPage component.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The localhost logic was causing confusion. The production URL works fine for local development.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Set iframe src only on initial load, not on every URL change
- This prevents a feedback loop where iframe updates cause it to reload
- Parent URL still updates when iframe sends postMessage events

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Reverted AppPage to original state, then added conditional logic
- URL parameter passing and message handling only applies to obbba-household-by-household
- Other iframe apps continue to work as before without deep linking
- Prevents iframe reload when URL changes originate from the iframe

This ensures the deep linking functionality is only applied where needed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 2030b9f into master Jul 24, 2025
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in policyengine-app Jul 24, 2025
@MaxGhenis MaxGhenis deleted the MaxGhenis/issue2701 branch July 24, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix the deep links in the OBBBA household by household explorer

2 participants