Skip to content

Conversation

@a1012112796
Copy link
Member

fix #36071

looks that's because if an svg in hiden env, it's color added by fill="url(#a)" will become not usefull. by ai helping, I think moving it out of page by position is a good solution. fell free creat a new pull request if you have a better soluton. Thanks.
image

fix go-gitea#36071

looks that's because if an svg in hiden env, it's color
added by `fill="url(#a)"` will become not usefull. by ai helping,
I think moving it out of page by position is a good solution.
fell free creat a new pull request if you have a better soluton.
Thanks.

Signed-off-by: a1012112796 <1012112796@qq.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 3, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 3, 2025
@a1012112796 a1012112796 added the topic/ui Change the appearance of the Gitea UI label Dec 3, 2025
@silverwind
Copy link
Member

silverwind commented Dec 3, 2025

Interesting bug. I can reproduce on Chrome and Safari, but not on Firefox. I think the root cause must be some obscure mechanism where some SVG elements like this linearGradient inherit some CSS properties, like in this case display: none.

I can't think of a better fix, but please move this CSS into web_src/css/base.css:

.hide-absolute {
  position: absolute;
  left: -9999px;
}

@wxiaoguang
Copy link
Contributor

@silverwind
Copy link
Member

You mean the styling of .ui .form .autofill-dummy? It's not quite the same as this.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 4, 2025

You mean the styling of .ui .form .autofill-dummy? It's not quite the same as this.

I didn't say "same". I mean "similar":

  1. They are all caused by uncontrollable and unclear browser's behaviors
  2. They all need "not really hidden" but "visually not existing" elements
  3. They all have complex backgrounds and need comments to explain, otherwise the future readers won't understand

For this case, these styles work without magic number:

... {
    position: absolute;
    width: 0px;
    height: 0px;
    overflow: hidden;
}

@silverwind
Copy link
Member

silverwind commented Dec 4, 2025

Generally speaking I would avoid SVG "icon maps" with xlink. There are too many obscure browser behaviours/bugs related to xlink and rendering the SVG directly is best to avoid those.

@silverwind
Copy link
Member

Oh and btw, xlink:href is deprecated: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/xlink:href.

@wxiaoguang
Copy link
Contributor

Generally speaking I would avoid SVG "icon maps" with xlink. There are too many obscure browser behaviours/bugs related to xlink and rendering the SVG directly is best to avoid those.

xlink was used to avoid duplicate SVG contents to reduce page size.

It should be easy to remove the xlink and render the icon directly. I am fine with either approach.

@silverwind
Copy link
Member

I don't think the size impact will really matter. On a big page, there may be 100 icons, which shouldn't be more than a few kBs.

@wxiaoguang
Copy link
Contributor

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 4, 2025

I don't think the size impact will really matter. On a big page, there may be 100 icons, which shouldn't be more than a few kBs.

Not a few, but dozens of or hundreds of.

image

@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 Dec 4, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 4, 2025
@silverwind silverwind merged commit ee365f5 into go-gitea:main Dec 4, 2025
23 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Dec 4, 2025
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Dec 4, 2025
fix go-gitea#36071

looks that's because if an svg in hiden env, it's color added by
`fill="url(#a)"` will become not usefull. by ai helping, I think moving
it out of page by position is a good solution. fell free creat a new
pull request if you have a better soluton. Thanks.
<img width="2198" height="1120" alt="image"
src="https://github.com/user-attachments/assets/bbf7c171-0b7f-412a-a1bc-aea3f1629636"
/>

---------

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Dec 4, 2025
lunny pushed a commit that referenced this pull request Dec 4, 2025
Backport #36078 by @a1012112796

fix #36071

looks that's because if an svg in hiden env, it's color added by
`fill="url(#a)"` will become not usefull. by ai helping, I think moving
it out of page by position is a good solution. fell free creat a new
pull request if you have a better soluton. Thanks.
<img width="2198" height="1120" alt="image"
src="https://github.com/user-attachments/assets/bbf7c171-0b7f-412a-a1bc-aea3f1629636"
/>

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@a1012112796 a1012112796 deleted the zzc/dev/file_icon_ui branch December 5, 2025 00:17
zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 5, 2025
* giteaofficial/main:
  Add strikethrough button to markdown editor (go-gitea#36087)
  Move commit related functions to gitrepo package (go-gitea#35600)
  Fix the bug when ssh clone with redirect user or repository (go-gitea#36039)
  fix some file icon ui (go-gitea#36078)
  update golangci-lint to v2.7.0 (go-gitea#36079)
  Use Golang net/smtp instead of gomail's smtp to send email (go-gitea#36055)
  Fix edit user email bug in API (go-gitea#36068)
  [skip ci] Updated translations via Crowdin
@xnox xnox mentioned this pull request Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code topic/ui Change the appearance of the Gitea UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File icon is not shown for *.kts and *.xml file

5 participants