Skip to content

use-first-commit-message-for-new-prs - Do not replace title on page reload - #7198

Closed
pgimalac wants to merge 2 commits into
refined-github:mainfrom
pgimalac:pgimalac/fix-title-commit-on-reload
Closed

pgimalac wants to merge 2 commits into
refined-github:mainfrom
pgimalac:pgimalac/fix-title-commit-on-reload

Conversation

@pgimalac

Copy link
Copy Markdown
Contributor

Closes #7191.

Do not set the title to the first commit message on page reload.
It avoids overwriting user input.

The feature still works on page load, but not on reload, github just restores whatever input was before, whether the first commit title or user input.

Test URLs

https://github.com/pgimalac/refined-github/compare/main...pgimalac:refined-github:pgimalac/fit-rendered-markdown?expand=1

Screenshot

Enregistrement.de.l.ecran.2023-12-31.a.17.53.54.mov

@pgimalac pgimalac changed the title use-first-commit-message-for-new-prs: do not replace title on page reload use-first-commit-message-for-new-prs - Do not replace title on page reload Dec 31, 2023

@fregante fregante left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be more comfortable targeting this specific GitHub behavior rather than guess the user action. It seems to be easy at this point, assuming that our code runs before Github's session:resume event:

function init () {
  if (sessionStorage.getItem(`session-resume:/${getRepo()?.nameWithOwner}/compare`)) {
	  return false;
  }
  
  // …
}

@fregante
fregante marked this pull request as draft January 17, 2024 06:47
@pgimalac

Copy link
Copy Markdown
Contributor Author

Hey @fregante, sorry for the delay, I gave it a try but it doesn't work, the code runs before the field is reloaded (the title is the branch name, which is the default) but there is no session-resume in the sessionStorage...

@fregante

fregante commented Jan 21, 2024 •

Copy link
Copy Markdown
Member

session:resume is an event on window. Either way we don't need to do anything about it

@pgimalac

Copy link
Copy Markdown
Contributor Author

session:resume is an event on window. Either way we don't need to do anything about it

I'm not sure I understand, do you want me to do anything about this PR then ?

@fregante

Copy link
Copy Markdown
Member

do you want me to do anything about this PR then ?

I posted the piece of code I'd like to see inside init. Does that fix the issue? In my manual tests it worked

@pgimalac

Copy link
Copy Markdown
Contributor Author

Hey @fregante, sorry for the delay, I gave it a try but it doesn't work, the code runs before the field is reloaded (the title is the branch name, which is the default) but there is no session-resume in the sessionStorage...

As I said in my previous message I tried replacing the block I added with the one you wrote using session-resume, but it didn't work. I printed all sessionStorage key/value and none were session-resume...
It worked for you ?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

use-first-commit-message-for-new-prs overrides user set title when refreshing page

2 participants