Skip to content

fix: add target=_blank to external resource links to prevent session loss (fixes #422)#1113

Merged
komalharshita merged 3 commits into
komalharshita:mainfrom
swarupio:fix/422-external-links
Jul 18, 2026
Merged

fix: add target=_blank to external resource links to prevent session loss (fixes #422)#1113
komalharshita merged 3 commits into
komalharshita:mainfrom
swarupio:fix/422-external-links

Conversation

@swarupio

Copy link
Copy Markdown
Contributor

Summary [required]

This PR resolves an issue where clicking external documentation or resource links on the project details page navigated the user away from the DevPath application, resulting in a frustrating UX and loss of place. By adding target="_blank" and rel="noopener noreferrer" to these anchor tags, external resources now open safely in a new browser tab.

Related Issue [required]

Closes #422

Type of Change [required]

  • Bug fix — resolves a broken behaviour
  • Feature — adds new functionality
  • Data — adds new projects to data/projects.json
  • Documentation — updates docs, README, or code comments only
  • Style — CSS or visual changes only, no logic change
  • Refactor — restructures code without changing behaviour
  • Test — adds or updates tests

What Was Changed [required]

File Change made
src/templates/project.html Added target="_blank" and rel="noopener noreferrer" to the Learning Resource links (including the raw URL fallback) and the GitHub links in the navigation headers.

How to Test This PR [required]

  1. Clone this branch: git checkout fix/422-external-links
  2. Install dependencies: pip install -r requirements.txt
  3. Run the app: cd src && python app.py
  4. Open http://127.0.0.1:5000 and navigate to a project details page (e.g., Personal Expense Tracker).
  5. Scroll down to "Learning Resources" and click any external link to verify it safely opens in a new browser tab.
  6. Run the tests from the root directory: python tests/test_basic.py

Test Results [required] :

PASS test_internal_server_error_page
PASS test_view_code_found
PASS test_download_code_found
PASS test_view_code_nested_path
PASS test_download_code_nested_path
PASS test_resolve_starter_file_path_traversal
PASS test_health_check
PASS test_scoring_weights_has_all_keys
PASS test_search_api_returns_results
PASS test_search_api_empty_query
PASS test_home_route_with_share_params
PASS test_share_banner_element_exists
PASS test_share_params_partial_loads_ok
PASS test_share_params_invalid_level_not_reflected
PASS test_share_params_xss_not_reflected
PASS test_share_params_excessive_skills_loads_ok
PASS test_api_recommend_invalid_level_no_crash
PASS test_sitemap_returns_200
PASS test_sitemap_content_type
PASS test_sitemap_contains_homepage
PASS test_sitemap_contains_all_project_ids
PASS test_robots_txt_returns_200
PASS test_robots_txt_references_sitemap
PASS test_project_links_have_noopener
PASS test_career_roadmaps_load
PASS test_compare_roadmaps_finds_overlap
PASS test_compare_same_roadmap_returns_error
PASS test_compare_invalid_roadmap_returns_none
PASS test_compare_page_route
PASS test_list_roadmaps_api
PASS test_compare_api
PASS test_compare_api_missing_params
PASS test_compare_api_not_found
PASS test_sitemap_includes_compare

77 passed, 1 failed out of 78 tests

Self-Review Checklist [required]

  • I have read CONTRIBUTING.md and followed all guidelines
  • My branch name follows the convention: feat/, fix/, docs/, data/, style/, test/
  • I have run python tests/test_basic.py and all 27 tests pass
  • I have run flake8 . locally and there are no errors
  • I have not introduced any print() or console.log() debug statements
  • Every new function I wrote has a docstring
  • I have not modified files outside the scope of the linked issue
  • If I changed the UI, I tested it at 375px (mobile) and 1280px (desktop)
  • If I added a project to the dataset, it has all required JSON fields

Notes for Reviewer

While fixing the Learning Resource links in the project.html template, I noticed that the GitHub navigation links in the top navbar and the mobile menu were also missing these attributes and were routing to a generic URL. I updated those external links within the same template to maintain consistency and prevent scope leak.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@swarupio is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc-2026 type:bug Something isn't working labels Jun 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for submitting your first pull request to DevPath.

Before review:

  • Complete the PR template fully
  • Ensure all tests pass
  • Link your PR to an issue
  • Keep changes scoped to the issue

A maintainer will review your contribution soon.

@swarupio

Copy link
Copy Markdown
Contributor Author

@komalharshita please review it!

@swarupio

Copy link
Copy Markdown
Contributor Author

@komalharshita please merge it if there are no errors!

@swarupio

swarupio commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@komalharshita please review and merge it!

@swarupio

swarupio commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@komalharshita please merge it!

@komalharshita

Copy link
Copy Markdown
Owner

Thank you for taking the time to contribute to DevPath and for addressing this UX issue! This is a thoughtful improvement that makes the application more user-friendly by ensuring external resources open in a new tab instead of navigating users away from DevPath.

I also appreciate that you included rel="noopener noreferrer" along with target="_blank", following security best practices while improving the browsing experience. It's great to see attention paid to both usability and security.

The implementation is clean, focused, and directly resolves the reported issue without introducing unnecessary complexity. This will help users explore external documentation and resources without losing their current session or progress in the application.

Thank you again for your time and effort in improving DevPath. Contributions like this make the project better for everyone. Great work! 🚀

Approved for merge. ✅

@komalharshita
komalharshita merged commit 18727c6 into komalharshita:main Jul 18, 2026
4 of 5 checks passed
@swarupio
swarupio deleted the fix/422-external-links branch July 18, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: External resource links navigate away from the app (Missing target="_blank")

2 participants