Issue regarding the Issue cache function: Permalink does not update after using the "Back" button on the creation screen. #200393
-
🏷️ Discussion TypeBug BodyOverview and backgroundWhen creating an issue from the code view, I used the browser's "Back" function intending to change the selected lines of code. However, upon modifying the code and navigating to the issue, the code remained unchanged. This prompted an investigation into the caching mechanism. Furthermore, even when the cancel button is used, the code view after the redirect restores the old selection state; consequently, the issue creation screen generates the old permalink. and,Accessing the discussion page also results in an error. Cause: Persistence of initial parameters
Regarding specific aspects (symbols/identifiers) that differ from my own findings,
ProposedIntroduce a useEffect(() => {
const syncPermalink = () => {
const params = new URLSearchParams(window.location.search);
setPermalink(params.get("permalink") || "");
};
// Sync on initial render
syncPermalink();
// Listen for browser back/forward (popstate)
window.addEventListener("popstate", syncPermalink);
return () => window.removeEventListener("popstate", syncPermalink);
}, []);Generally expected behavior:If a user navigates back using the "Back" button and then selects a new range, the permalink on the issue creation screen should update to reflect the newly selected range. This is because the "Code" and "Issues" pages are distinct sections. Page navigation and the intuition behind "Back":In GitHub's architecture, "Code" and "Issues" are completely independent, major categories. The process of selecting a code range and creating a new issue is, in fact, a "page transition." Cancel" button:To the user, the "Cancel" button on the issue creation screen appears to mean only "discard the text of the issue currently being written." Consistency with standard GitHub issue behavior:
Normally, when creating an issue, it appears in a modal window overlaid on the current screen. To write in full-screen mode, one must click the full-screen button in the top-right corner. Based solely on its visual appearance, no one would intuitively understand that this is a "reset button to clear the backend or frontend cache for code selection." *While this may be a separate issue, the lack of a "Save Draft" button is also a contributing factor. 【CASE1】The permalink does not update after using the "Back" button on the creation screen.
Chrome is up to date Version 150.0.7871.47 (Official Build) (64-bit) win11
【CASE2】I executed "Cancel" on the task and changed the line number range.
【CASE3】If you execute "Cancel" and reopen the ISSUE without changing the line number range, it succeeds.
As explained in CASE 2, this phenomenon occurs because the initial cache is cleared upon cancellation and the previous line range is set; this is the underlying mechanism. Consequently, if you navigate to the ISSUE page by clicking "ISSUEnew" without changing the line range in the code view, the page will reflect the permalink for the previously set line range. The expectations associated with the word "New"
When users click the "Reference in new issue" button, they expect to create something fresh from scratch using the latest state they have currently selected. Transient state should be discarded: The act of selecting a line of code is a transient state (much like an SNS share button). The system is responsible for completely clearing this transient state (cache) the moment the user returns to the previous screen using the browser's "Back" function. 【CASE4】Switch the browser to Edge and reproduce Case 3.
Microsoft Edge is up to date.Version 149.0.4022.98 (Official build) (64-bit) Privatemode.
【CASE5】I checked the Discussion section as well, but there was an error.
【CASE6】Reproduce #194956When I reproduced it, there was no change. Source:https://github.com/octokit/octokit.js/blob/v5.0.5/src/index.ts That is all. Thank you for reading to the end. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the detailed investigation and for referencing the earlier discussion. Your reproduction steps across multiple scenarios and browsers make it easier to understand the behavior. One thing that stands out is that both the browser Back flow and the Cancel flow appear to preserve the originally selected permalink, even after a new line range has been selected. That suggests the selected code reference may be treated as persistent client-side state instead of being refreshed from the current URL or selection whenever a new issue is opened. I also agree with your point about user expectations. When a user selects a new range and chooses "Reference in new issue", they would generally expect the newly selected lines to be used rather than a previously cached selection. Hopefully the additional reproduction cases and cross-browser testing help the GitHub team determine whether this is an intentional optimization or a client-side state management issue. |
Beta Was this translation helpful? Give feedback.
-
|
@sahare-mayur-0071 Thank you for your comment!! I would like to add some details regarding the behavior. Initially, I thought the error occurred simply during a "Back" operation. I realized I hadn't actually clicked the "Cancel" button; when I did click it, the behavior seemed similar, so I investigated further. Clicking the "Cancel" button triggers the following background processes:Recap of what has been confirmed so far
Add scenario: Entering text and then clicking CancelEntering text causes "Discard changes?" to appear. My previous verification involved opening the ISSUE view from the code view, where the permalink is automatically inserted into the title and body input fields. However, this gif, text is entered into the title or body fields before clicking "Cancel," a confirmation modal appears.
First, select lines L1 through L3. The ISSUE view displays lines L1 through L10. Next, enter some text after the permalink.
Could this difference in behavior be caused by caching?Result: Clicking the "Cancel" button leaves the permalink intact but clears the entered text.I tested a scenario where text was entered into the title and body fields. While the caching behavior itself remained unchanged, the entered text was lost.
To summarize the situation:
Behavior However, because the state remains locked to the previous cache, any changes are not reflected if the user opens the issue again (even when attempting to create a "New Issue"). 【Pattern1】If maintaining the structure that transitions from code to an issue.Change the label "Cancel" to something like "Back."An image showing how it would look if the label were changed to "back" [Proposal: Changing the label to "Back" on the issue page (mockup)] *Note, however, that for standard issues, the body text is entered via a modal window on the issue list screen, so "Cancel" is appropriate in that case. When creating a new issue, it initially appears in a modal window.I have verified this behavior.
For "Standard" issues, the display is overlaid, so the only available options are "Close" or "Cancel." This modal overlay was likely implemented to reduce the friction of page transitions when viewing details from the issue list. There is a full-screen button in the top-right corner. To close the modal window, please click "Cancel." This is presumably the reason why the "Cancel" button exists. Regarding the issue from the code view: As mentioned earlier, since the user is working within the "Issues" page, "Back" is more appropriate than "Cancel" from a usability perspective. Alternatively, another option is to display a message such as: "Returning and re-selecting will preserve the issue cache. Please go back to the previous step and create a new issue with the same selections." 【Pattern2】 If the "Cancel" label is retained(If left without modification):By displaying the "New Issue" screen as a modal window over the code view, it becomes clear that "Cancel" simply closes that modal window. This is also an example of what happens when the "New Issue" screen is displayed over the code view. Switching to a modal window (dialog): 【Proposal: Modal Display over Code View (Mockup)】 However, modal windows have limited display space. While suitable for short text, they may feel cramped for displaying detailed content like an Issue. There is also a risk that it may become unclear to the user whether a draft has been saved. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for taking the time to investigate this further and for sharing the additional scenarios. The distinction you found between using Back and Cancel, especially when unsaved text triggers the "Discard changes?" dialog, adds useful context. It suggests that there may be separate state-management paths for the issue draft and the referenced permalink. I also think your UX observations are valuable. From a user's perspective, "Reference in new issue" implies that the current code selection will always be used. If the previous selection is intentionally preserved, the interface should make that behavior clearer to avoid confusion. Whether the underlying behavior is an intentional optimization or a bug, the additional reproduction cases and comparison of the different navigation flows provide much more information for the GitHub team to evaluate. Thanks again for documenting the different scenarios so thoroughly. |
Beta Was this translation helpful? Give feedback.













Thanks for the detailed investigation and for referencing the earlier discussion.
Your reproduction steps across multiple scenarios and browsers make it easier to understand the behavior. One thing that stands out is that both the browser Back flow and the Cancel flow appear to preserve the originally selected permalink, even after a new line range has been selected.
That suggests the selected code reference may be treated as persistent client-side state instead of being refreshed from the current URL or selection whenever a new issue is opened.
I also agree with your point about user expectations. When a user selects a new range and chooses "Reference in new issue", they would generally …