@@ -44,6 +44,7 @@ func bannerComponent(props react.Props) *react.Element {
4444
4545 version , setVersion = react .UseState (`--` )
4646 shareHash , setShareHash = react .UseState (`` )
47+ prevShareHashRef = react .UseRefWith (`` )
4748 runButtonRef = react .UseRef ()
4849 shareUrlRef = react .UseRef ()
4950 lightTheme , setLightTheme = react .UseStateLazy (getDefaultToLightTheme )
@@ -66,7 +67,17 @@ func bannerComponent(props react.Props) *react.Element {
6667
6768 // This updates the top window's URL hash when the share hash state has changed.
6869 react .UseEffect (func () {
69- url .SetUrlHash (shareHash )
70+ // if shareHash is empty, then either this is the initial state or
71+ // clearing out the hash because of a code change
72+ if shareHash == `` {
73+ prevHash := prevShareHashRef .Current ()
74+ if prevHash != `` && url .GetUrlHash () == prevHash {
75+ url .SetUrlHash (`` )
76+ }
77+ } else {
78+ url .SetUrlHash (shareHash )
79+ }
80+ prevShareHashRef .SetCurrent (shareHash )
7081 }, []any {shareHash })
7182
7283 onFormatClick := react .UseCallback (func () {
@@ -111,7 +122,7 @@ func bannerComponent(props react.Props) *react.Element {
111122 // based on the URL Hash, determine which UI elements to show.
112123 shareUrlClass := `share-url-hidden`
113124 snippetsClass := `snippets-drop-down-show`
114- selSnippet := snippets . DefaultName
125+ selSnippet := ``
115126 shownSharedUrl := ``
116127 if len (shareHash ) > 0 {
117128 if strings .HasPrefix (shareHash , `#/` ) {
0 commit comments