Skip to content

fix(changelog): correct variable declarations in populatePackageNames…#671

Open
vivekv1504 wants to merge 1 commit intowebex:nextfrom
vivekv1504:changelog-widget-small
Open

fix(changelog): correct variable declarations in populatePackageNames…#671
vivekv1504 wants to merge 1 commit intowebex:nextfrom
vivekv1504:changelog-widget-small

Conversation

@vivekv1504
Copy link
Copy Markdown
Contributor

@vivekv1504 vivekv1504 commented Apr 9, 2026

…function

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

Problem

The populatePackageNames function had two variables incorrectly
declared with const that were being reassigned, which violates
JavaScript const semantics:

by making the following changes

Code quality improvement: Fix variable declaration issues in the
changelog package selector.

  1. sortedPackages - Assigned different values based on whether
    special packages exist
  2. optionsHtml - Concatenated with += operator in a loop

Solution

Changed both declarations from const to let to allow
reassignment.

javascript
// Before
const sortedPackages = [];
const optionsHtml = '<option...>';

// After
let sortedPackages;
let optionsHtml = '<option...>';

Impact
Code now follows JavaScript best practices
No functional changes to user experience
Prevents potential bugs from const reassignment
Improves code maintainability

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
    < ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.

@vivekv1504 vivekv1504 requested a review from a team as a code owner April 9, 2026 19:21
@vivekv1504 vivekv1504 added the validated Indicates that the PR is ready for actions label Apr 9, 2026
@aws-amplify-us-east-2
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-671.d1b38q61t1z947.amplifyapp.com

commits.length
);

updateEnhancedComparisonURL(stableA, stableB, selectedPackage, finalVersionA, finalVersionB);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we removing this?

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.

There are two calls to updateEnhancedComparisonURL happening on every comparison
call1 :Line 791 (inside compareAndRenderPackageVersions)
call2:Line 1288 (in the submit handler, right after calling compareAndRenderPackageVersions)

What updateEnhancedComparisonURL does(916):
Each call invokes window.history.pushState(...), which pushes a new entry into the browser's history stack. Since both calls happen with the same URL, you end up with two identical history entries for a single comparison action.

The visible symptom is that if a user clicks the browser's Back button after a comparison, they don't go back to the previous page — instead they stay on the same URL (because the first Back just undoes the duplicate push).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, Vivek. Do we need this to be done in the SDK as well in that case?

Also today, when I press back button, the URL changes but the UI remains the same.

Copy link
Copy Markdown
Contributor

@mkesavan13 mkesavan13 left a comment

Choose a reason for hiding this comment

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

Once again, do we need this to be done in the SDK as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated Indicates that the PR is ready for actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants