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 #1035 : Column alignment when zoom font only settings in browser #1036

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

hexaltation
Copy link
Collaborator

@hexaltation hexaltation commented Jun 12, 2024

fix #1035

Use rem value instead of fixed pixel where needed.
Removed inline style 52px for .gridview_data_row_num

Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

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

It works much better, thanks!

For the other reviewers, the "zoom text only" feature is used for people with visual deficiencies, so that improves the accessibility.

Here is a preview (you must use Firefox, Chrom* browsers don't have such feature):

Without the patch

recording-orig-behavior.mp4

With the patch

recording.mp4

app/client/components/GridView.js Outdated Show resolved Hide resolved
app/client/components/GridView.js Outdated Show resolved Hide resolved
@fflorent fflorent added the anct label Jun 13, 2024
@paulfitz
Copy link
Member

(apologies, I'm going to use this PR as a guinea pig to examine exactly why our machinery for deploying previews of PRs doesn't function for PRs from forks)

@paulfitz paulfitz added the preview Launch preview deployment of this PR label Jun 13, 2024
@@ -70,7 +70,8 @@ const SHORT_CLICK_IN_MS = 500;
// size of the plus width ()
const PLUS_WIDTH = 40;
// size of the row number field (we assume 4rem)
const ROW_NUMBER_WIDTH = 52;
const ROW_NUMBER_WIDTH_REM = 4;
const ROW_NUMBER_WIDTH_PX = 3.25 * ROW_NUMBER_WIDTH_REM; // 52px when no text zoom is applied
Copy link
Contributor

@berhalak berhalak Jun 19, 2024

Choose a reason for hiding this comment

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

Hi @hexaltation.

Can you extend the comment here with the math behind it? How 4 * 3.25 * root font size equals 52px ?

Copy link
Collaborator Author

@hexaltation hexaltation Jun 20, 2024

Choose a reason for hiding this comment

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

Hello @berhalak

I pushed a more (I hope) explicit comment.

The problem is I don't know why a factor of 3.25 have to be applied, except that 52px is the working value in InitialOffset and MiddleOffset.

May be it's better to get rid of ROW_NUMBER_WIDTH_PX and make the 3.25 factor appear by magic in Offsets formulas.

const initialOffset = -this.frozenWidth() - 3.25 * ROW_NUMBER_WIDTH + this.width() - revealWidth - PLUS_WIDTH;
const middleOffset = -this.frozenWidth() - 3.25 * ROW_NUMBER_WIDTH_PX + this.width() / 2;

Let me know

@dsagal
Copy link
Member

dsagal commented Jun 20, 2024

One note I'd like to add is to be sure to test this with frozen columns.

@hexaltation
Copy link
Collaborator Author

hexaltation commented Jun 20, 2024

(apologies, I'm going to use this PR as a guinea pig to examine exactly why our machinery for deploying previews of PRs doesn't function for PRs from forks)

If it can improve this workflow it's a pleasure :)

@paulfitz
Copy link
Member

(apologies, I'm going to use this PR as a guinea pig to examine exactly why our machinery for deploying previews of PRs doesn't function for PRs from forks)

If it can improve this workflow it's a pleasure :)

Update: we know what the issue is, and making it works needs some rejiggering to the workflow that @SleepyLeslie will be looking at.

Copy link
Contributor

@berhalak berhalak left a comment

Choose a reason for hiding this comment

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

I'm still confused a little bit :). In this line:

// as 1rem=16px -> 3.25 * 4 * 16 = 52px when no text zoom is applied
  • 1rem equals to 13px in Grist, not 16px
  • The math is wrong, even for 16px, the expression equals to 208px

I think it will be hard to do the math here properly, as the effect you want to achieve is a mix of font-size width and absolute width zooming. In your video, font is made bigger, but columns widths are not changed. Only the row number div is scaled. The math used for scrolling or calculating frozen offset doesn't assume that, it looks like a coincident that it works. I think we have some sanity checks and some values are trimmed, and it somehow works.

I think that the proper behavior is in the video below:

zoom-font.mp4

And this can be easily achived by replacing all 4rem and 4em sizes with 52px in GridView.css.

@hexaltation hexaltation changed the title fix: Column alignment when zoom font only settings in browser fix: Column alignment when zoom font only settings in browser #1035 Jul 10, 2024
@hexaltation hexaltation self-assigned this Jul 10, 2024
@hexaltation hexaltation changed the title fix: Column alignment when zoom font only settings in browser #1035 fix #1035 : Column alignment when zoom font only settings in browser Jul 10, 2024
@hexaltation
Copy link
Collaborator Author

@berhalak I've made the needed changes according to your suggestions.
Can you re-review it ?

@hexaltation
Copy link
Collaborator Author

One note I'd like to add is to be sure to test this with frozen columns.

👍

Copy link
Contributor

Deployed commit 3678ab2232d61f81538b4884ebd66a6b81302e3b as https://grist-hexaltation-grist-core-1035-align-columns-when-zoom.fly.dev (until 2024-08-22T10:04:23.218Z)

@berhalak
Copy link
Contributor

Thanks @hexaltation !

@berhalak berhalak merged commit 0272b67 into gristlabs:main Jul 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
anct preview Launch preview deployment of this PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Columns no longer align when Font zoom is set in web Browser
5 participants