Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:Circular loading spinner is oval in safari browser #29713

Closed
wants to merge 10 commits into from

Conversation

HEREYUA
Copy link
Contributor

@HEREYUA HEREYUA commented Mar 11, 2024

Fix:#29041

When defining height and aspect-ratio, Safari will calculate the width based on these two values. However, it appears that Safari applies the aspect-ratio based on the total height (which includes border-width), which may cause the total width of the element to be twice the border-width more than the total height.

image

When defining width and aspect-ratio, it seems that Safari accurately calculates the height based on these two values

image

Update:
In the following discussion, we found the same issue on the webkit bug:https://bugs.webkit.org/show_bug.cgi?id=267625

When absolute positioning is not used on ::after, the problem mentioned above can be avoided, but this might affect some UI

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 11, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 11, 2024
@techknowlogick techknowlogick added type/bug backport/v1.21 This PR should be backported to Gitea 1.21 labels Mar 11, 2024
techknowlogick
techknowlogick previously approved these changes Mar 11, 2024
Copy link
Member

@techknowlogick techknowlogick left a comment

Choose a reason for hiding this comment

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

thanks so much!

@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 Mar 11, 2024
@silverwind
Copy link
Member

silverwind commented Mar 11, 2024

This will likely break this rule below which only sets height:

height: var(--height-loading);

Further below, another variant sets both:

width: 1.25rem;
height: 1.25rem;

So I think we should make all 3 rules the same, either set only 1 dimension, or both in all three rules.

Regarding the Safari issue: Does changing box-sizing fix it? It sounds like a Webkit bug, check https://bugs.webkit.org/.

@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 11, 2024

This will likely break this rule below which only sets height:

height: var(--height-loading);

Further below, another variant sets both:

width: 1.25rem;
height: 1.25rem;

So I think we should make all 3 rules the same, either set only 1 dimension, or both in all three rules.

Regarding the Safari issue: Does changing box-sizing fix it? It sounds like a Webkit bug, check https://bugs.webkit.org/.

I tried changing box-sizing but it did not solve it, Perhaps we can either set only the width dimension or set both width and height. Which one do you think is better?

@silverwind
Copy link
Member

Ideally we set only one dimension and aspect-ratio, and the assumption was that that works in all browsers, no matter which dimension is set. I suggest we create a standalone https://jsfiddle.net/ example to showcase the Safari issue, and then investigate the possible workarounds.

I prefer using height over width because that is most likely the limiting dimension for the spinner.

@silverwind
Copy link
Member

silverwind commented Mar 11, 2024

I think this might be the related bug, but there are also others.

@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 11, 2024

I think this might be the related bug, but there are also others.

I might have found the related one in the list you provided:https://codepen.io/legion80/pen/ZEPeLdz
It displays correctly when absolute positioning is not used on ::after(It has been centered using flex layout)
image

@silverwind
Copy link
Member

Yes, it's the same bug. It's strange that it only happens with height but not width. The workaround is likely good but we should add a link comment to the webkit bug and adjust the two subsequent selectors I linked to only set width.

@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 12, 2024
@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 12, 2024

I've made the adjustment:3102bd9

@silverwind
Copy link
Member

Hmm, we need to be really careful with these spinner CSS adjustments, they are used in many places in the UI.

@techknowlogick techknowlogick dismissed their stale review March 12, 2024 23:43

Per conversation

@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 12, 2024
@HEREYUA HEREYUA closed this Mar 13, 2024
@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 13, 2024

Hmm, we need to be really careful with these spinner CSS adjustments, they are used in many places in the UI.

You're right, could there possibly be something that I've missed in my adjustments? Perhaps we can also opt for minimal changes, just fixing the positioning issue with ::after, so that even if the height and aspect-ratio are used together, it won't cause a problem on Safari.

@HEREYUA HEREYUA reopened this Mar 13, 2024
@silverwind
Copy link
Member

I'd say keep changeset minimal to fix the issue. I think just switching width to height in the .is-loading class and the classes below that extend the selector. There might also be some non-CSS code that adjust height currently, if they exist, they need to switch as well. Also add a comment linking to the webkit bug.

@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 13, 2024

I'd say keep changeset minimal to fix the issue. I think just switching width to height in the .is-loading class and the classes below that extend the selector.

updated

There might also be some non-CSS code that adjust height currently, if they exist, they need to switch as well.

It seems that no results were found through the is-loading search.

Also add a comment linking to the webkit bug.

updated

@wxiaoguang
Copy link
Contributor

It breaks the loading UI http://localhost:3000/devtest/gitea-ui

Before:

image

After:

image

@HEREYUA
Copy link
Contributor Author

HEREYUA commented Mar 14, 2024

It breaks the loading UI http://localhost:3000/devtest/gitea-ui

Before:

image

After:

image

This seems to be caused by the flexible layout, it doesn't seem to be an effective method to solve

@silverwind
Copy link
Member

silverwind commented Mar 14, 2024

It does reproduce on the /devtest page, let's see if I find a simpler fix.

image

@silverwind
Copy link
Member

Found a better workaround: #29801

@techknowlogick
Copy link
Member

Thanks for your effort in this PR @HEREYUA, I think we'll use the alternative proposed in the other PR. This PR was helpful in progressing towards the solution and is very much appreciated :)

techknowlogick pushed a commit that referenced this pull request Mar 14, 2024
Fixes: #29041
Fixes: #29713

Any of the `width: *-content` properties seem to workaround this Webkit
bug, this one seemed most suitable.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 14, 2024
Fixes: go-gitea#29041
Fixes: go-gitea#29713

Any of the `width: *-content` properties seem to workaround this Webkit
bug, this one seemed most suitable.
silverwind added a commit that referenced this pull request Mar 14, 2024
Backport #29801 by @silverwind

Fixes: #29041
Fixes: #29713

Any of the `width: *-content` properties seem to workaround this Webkit
bug, this one seemed most suitable.

Before:
<img width="184" alt="Screenshot 2024-03-14 at 22 29 58"
src="https://github.com/go-gitea/gitea/assets/115237/6effc5f0-bc64-4752-be74-9c43b3974407">

After:
<img width="177" alt="Screenshot 2024-03-14 at 22 30 30"
src="https://github.com/go-gitea/gitea/assets/115237/5de244d7-6b46-428e-957c-4b10f53e2441">

Co-authored-by: silverwind <[email protected]>
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Mar 20, 2024
Fixes: go-gitea/gitea#29041
Fixes: go-gitea/gitea#29713

Any of the `width: *-content` properties seem to workaround this Webkit
bug, this one seemed most suitable.

(cherry picked from commit 35def319fdb8c73aa5e2c52fad5230d287e2bd93)
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Mar 22, 2024
Backport #29801 by @silverwind

Fixes: go-gitea/gitea#29041
Fixes: go-gitea/gitea#29713

Any of the `width: *-content` properties seem to workaround this Webkit
bug, this one seemed most suitable.

Before:
<img width="184" alt="Screenshot 2024-03-14 at 22 29 58"
src="https://github.com/go-gitea/gitea/assets/115237/6effc5f0-bc64-4752-be74-9c43b3974407">

After:
<img width="177" alt="Screenshot 2024-03-14 at 22 30 30"
src="https://github.com/go-gitea/gitea/assets/115237/5de244d7-6b46-428e-957c-4b10f53e2441">

Co-authored-by: silverwind <[email protected]>
(cherry picked from commit df23ec0f8b490bee49dc0e7944b529f3ede35301)
@lunny lunny removed the backport/v1.21 This PR should be backported to Gitea 1.21 label Mar 25, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants