Skip to content

Conversation

@silverwind
Copy link
Member

@silverwind silverwind commented May 30, 2024

  1. ContextPopup is now a stateless component, accepting only props to render the popup
  2. Loading state is gone, the requests are fast enough to not need a loading state
  3. Error state is gone, we don't need to show any errors on this, imho
  4. Popups now have the tooltip role which enables singleton behaviour, so multiple such popups won't show at the same time (happens when links are close together)
  5. Increased the interactiveBorder to 15px
  6. Tooltip init is now lazy
  7. Repo link in tooltip is now clickable

Fixes: #31161
Helps with: #30275

Popup over existing issue:

image

Nonexisting issue does not show anything:

image

I think this is a nice bugfix for 1.22.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 30, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/js labels May 30, 2024
@silverwind silverwind changed the title Rewrite context popup to stateless Make ContextPopup stateless May 30, 2024
@silverwind silverwind marked this pull request as draft May 30, 2024 14:50
@silverwind silverwind marked this pull request as ready for review May 30, 2024 14:59
@silverwind
Copy link
Member Author

silverwind commented May 31, 2024

In 434287a I added another data attribute to track the loading state, ensuring this will never issue two GET requests at the same time for the same link, no matter which DOM events trigger on the link.

@silverwind silverwind changed the title Make ContextPopup stateless Make ContextPopup stateless, improve fetching logic Jun 3, 2024
@yp05327 yp05327 added this to the 1.23.0 milestone Jun 4, 2024
@silverwind silverwind requested a review from wxiaoguang June 4, 2024 15:40
@wxiaoguang
Copy link
Contributor

Sorry but I do not think the change is good enough.

When you'd like to reuse an existing instance, all states should be handled carefully. For example

  • Hover on #1, then #1 is loading, then hover to #2, should #2 be loading immediately? (I do not see so in this PR)
  • Hover on #1, then #1 fails due to temp network error. Then re-hover on #1, will it reload?
  • Hover on #1, then #1 loads, then #1 changes, then re-hover on #1, will it reload?

I do not think it's worth to force it only use one instance.

I strongly prefer the old approach, which is simple enough and doesn't really cause any problem.

@silverwind
Copy link
Member Author

silverwind commented Jun 4, 2024

I think single instance is preferable because with the increased interactivity border, it's possible to have situations like this:

image

As for the other questions, I will check. Of course the last hovered instance should always win.

@wxiaoguang
Copy link
Contributor

I think single instance is preferable because with the increased interactivity border, it's possible to have situations like this:

I wouldn't say it is a serious problem, and it could be fixed by add some "hiding" code.

@silverwind
Copy link
Member Author

silverwind commented Jun 10, 2024

The problem with double tooltip can also be seen with the commit status in commit list. I think it could be fixed by adding a singleton="tooltip" during creation, so that only one instance per singleton can show. Currently this mechanism is active when role is tooltip but I think it may need to become more flexible.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 12, 2024
@silverwind silverwind marked this pull request as draft June 12, 2024 22:06
@lunny lunny modified the milestones: 1.23.0, 1.24.0 Sep 7, 2024
@wxiaoguang wxiaoguang removed this from the 1.24.0 milestone Dec 22, 2024
@wxiaoguang
Copy link
Contributor

Is it sill active? I do not see the edge cases in #31181 (comment) could be addressed clearly.

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Mar 13, 2025
@silverwind
Copy link
Member Author

silverwind commented Mar 14, 2025

I strongly prefer the old approach, which is simple enough and doesn't really cause any problem.

The old approach at least causes this problem of cached error state on back button:

#31161 (comment)

Also, a stateless component is much simpler than a stateful one, imho.

@wxiaoguang wxiaoguang removed their request for review March 23, 2025 15:40
@wxiaoguang
Copy link
Contributor

-> Fix "ref-issue" handling in markup #35739

@wxiaoguang wxiaoguang closed this Oct 24, 2025
}

export function initContextPopups() {
// TODO: Use MutationObserver to detect newly inserted .ref-issue
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need any new MutationObserver now.

My data-global-init framework works pretty well in #35739, and more and more global manually-called init functions can be removed.

Copy link
Member Author

@silverwind silverwind Oct 27, 2025

Choose a reason for hiding this comment

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

How does data-global-init detect new content from edits?

Copy link
Contributor

Choose a reason for hiding this comment

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

data-global-init is handled by a unique global MutationObserver, explained in Refactor global init code and add more comments #33755

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, global shared MutationObserver is also fine.

saschazepter pushed a commit to saschazepter/gitea that referenced this pull request Oct 27, 2025
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Oct 29, 2025
wxiaoguang added a commit that referenced this pull request Oct 29, 2025
Backport #35739 by wxiaoguang

This is a follow up for #35662, and also fix #31181, help #30275, fix
#31161

Co-authored-by: wxiaoguang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/go Pull requests that update Go code modifies/js modifies/templates This PR modifies the template files type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The PRs link in release page will get network error

7 participants