Skip to content

Conversation

@niravzxv
Copy link
Contributor

@niravzxv niravzxv commented Aug 3, 2025

fixes #14947

Summary

  • Fixes an issue where the "Save as Gist" button is disabled after any attempt, even on a failed save.
  • Now the button is only disabled after a confirmed, successful save (when a gist ID is returned).
  • This enhances UX by allowing retries if the gist save fails (e.g., user not logged in or network error).

Testing

  1. Launch the viewer locally (yarn serve-viewer).
  2. Load a Lighthouse JSON report.
  3. Attempt to "Save as Gist" with and without being logged in (Stayed enabled).

Note : Locally domain not authorized to log in success case need to test.

@niravzxv niravzxv requested a review from a team as a code owner August 3, 2025 16:58
@niravzxv niravzxv requested review from connorjclark and removed request for a team August 3, 2025 16:58
@google-cla
Copy link

google-cla bot commented Aug 3, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

only disable the button after a confirmed successful save,
allowing retry on failure.

fixes GoogleChrome#14947
only disable the button after a confirmed successful save,
allowing retry on failure.

fixes GoogleChrome#14947
Previously, the "Save as Gist" button was disabled immediately after any save attempt,
even if the gist creation failed (for example, if the user was not logged in).

This change updates the logic so that the button is disabled only after a confirmed,
successful save (when a gist ID is returned). This allows users to retry saving in case of failure.

Fixes GoogleChrome#14947
@niravzxv niravzxv changed the title Fix/save gist only on success fix(viewer): only disable save-gist button on successful save Aug 4, 2025
@niravzxv niravzxv changed the title fix(viewer): only disable save-gist button on successful save report(viewer): only disable save-gist button on successful save Previously, the "Save as Gist" button was disabled immediately after any save attempt, even if the gist creation failed (for example, if the user was not logged in). This change updates the logic so that the button is disabled only after a confirmed, successful save (when a gist ID is returned). This allows users to retry saving in case of failure. Fixes #14947 Aug 4, 2025
@niravzxv niravzxv changed the title report(viewer): only disable save-gist button on successful save Previously, the "Save as Gist" button was disabled immediately after any save attempt, even if the gist creation failed (for example, if the user was not logged in). This change updates the logic so that the button is disabled only after a confirmed, successful save (when a gist ID is returned). This allows users to retry saving in case of failure. Fixes #14947 report(viewer): only disable save-gist button on successful save Aug 4, 2025
Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

Seems to work, thanks!

A couple minor issues to resolve then we can merge.

btw I tested by using http://localhost:7333 rather than http://[::]:7333 - only the former is allowed to work in our Firebase settings.

const saveGistItem =
this._dom.find('.lh-tools__dropdown a[data-action="save-gist"]', this._dom.rootEl);
saveGistItem.setAttribute('disabled', 'true');
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this try/catch needed? _onSaveJson is already catching errors.

async _onSaveJson(reportJson) {
if (window.gtag) {
window.gtag('event', 'report', {type: 'share'});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

please don't make unnecessary / unrelated changes:

  • don't remove gtag call here
  • don't remove "@ private"
  • don't make whitespace changes (the comment above this function are misaligned, and the warning log at L174). maybe your IDE is reformatting stuff?

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

looks good, thanks!

@connorjclark connorjclark merged commit ddcf7d3 into GoogleChrome:main Aug 13, 2025
19 of 21 checks passed
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.

"Save as Gist" is grayed out in Viewer after first click

2 participants