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 RTL support in metadata component #4596

Merged

Conversation

unoduetre
Copy link
Contributor

@unoduetre unoduetre commented Jan 29, 2025

What

It was flagged that the metadata Arabic version requires structural changes. See the details in the document attached to the ticket. This change only relates to structural changes. The translations mentioned in that document have already been implemented by other tickets.

Why

Trello ticket

Visual Changes

Before

Screenshot 2025-01-29 at 15-44-50 مرشح المملكة المتحدة لانتخابات محكمة العدل الدولية لعام 2026 بروفيسور دابو أكانديه، كتيب الانتخابات - GOV UK

Zrzut ekranu z 2025-01-29 o 15 48 15

After

Screenshot 2025-01-29 at 15-45-11 مرشح المملكة المتحدة لانتخابات محكمة العدل الدولية لعام 2026 بروفيسور دابو أكانديه، كتيب الانتخابات - GOV UK

Zrzut ekranu z 2025-01-29 o 15 48 19

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 29, 2025 15:42 Inactive
@unoduetre
Copy link
Contributor Author

@matthillco I know you worked on a similar task previously. Please, let me know if you have any insights, e.g. if I need to watch out for something.

@unoduetre unoduetre marked this pull request as ready for review January 29, 2025 16:47
@unoduetre unoduetre force-pushed the 3214-fix-how-arabic-translation-is-structured-on-metadata branch from 32c5b4f to dd95ac0 Compare January 30, 2025 09:33
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 30, 2025 09:34 Inactive
@unoduetre unoduetre force-pushed the 3214-fix-how-arabic-translation-is-structured-on-metadata branch from dd95ac0 to 77fa6f5 Compare January 30, 2025 09:36
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 30, 2025 09:36 Inactive
@include govuk-media-query($from: tablet) {
float: right;
clear: right;
Copy link
Contributor

@jon-kirwan jon-kirwan Jan 30, 2025

Choose a reason for hiding this comment

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

Thanks, @unoduetre. The changes look great and work fine. I have one suggestion. I noticed that inline-start should automatically adjust positioning based on the content direction which would mean there may be no need to manually change the float position.

@media (min-width: 40.0625em) {
    dt.gem-c-metadata__term {
        float: inline-start;
    }

    dd.gem-c-metadata__definition {
        /* float: inline-start; */
    }
}

With this setup, the metadata component content appears to display correctly for both rtl and ltr.

Copy link
Contributor Author

@unoduetre unoduetre Jan 30, 2025

Choose a reason for hiding this comment

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

Yes, but float: inline-start started to be supported in e.g. Chrome 118. This version allows us to support grade C browsers as well. Do you think it makes more sense to not support grade C browsers (or they're already not supported for other reasons)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I thought we could continue to use it, since it's already implemented in a few places, perhaps as a progressive enhancement. However, it'd be great to hear @matthillco's thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

The RTL work that I undertook did not consider grade C browsers.

Logical properties have been available in evergreen browsers since 2021 and there are diminishing returns in continuing to support older browsers with fallback code. I believe we should be bold in bringing our codebases up to date.

However, there are some dangers with this approach. RTL styles implemented with logical properties have the potential to cause a page to be unreadable for some languages in unsupported browsers. So if in doubt, we can provide the fallback physical properties as well. Of course, if we're providing the fallback then there's an argument not to use the newer logical properties at all as it's just adding unnecessary code.

This is my personal view and may not align with the majority view in light of our browser support policies. If in doubt, you might want to refer this to one of the lead front-end devs for a different perspective.

Copy link
Contributor

Choose a reason for hiding this comment

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

The crux of it lies in this point "RTL styles implemented with logical properties have the potential to cause a page to be unreadable for some languages in unsupported browsers" - we need to ensure that we build for everyone. Our unsupported browsers may not give a good experience, but they shouldn't give an unreadable or unusable one. Without looking into the full detail of this PR I'd advise doing some testing to see the extent of the impact and making a call based on that. It may be necessary to avoid the newest methods for now.

Copy link
Contributor Author

@unoduetre unoduetre Jan 31, 2025

Choose a reason for hiding this comment

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

@maxgds Below I've added screenshots for comparison between a grade C browser (older version of Chrome) and a modern browser (newer version of Chrome). This is how the page will look like if we use float: inline-start. If we keep float: right, both will look like the newer one. I think the older version is acceptable, but let me know if you don't consider it as such.

Older (if we decide to use float: inline-start)

Screenshot 2025-01-31 at 09-28-07 Dashboard

Newer

Screenshot 2025-01-31 at 09-27-16 Dashboard

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks that makes it clear. I think the newer option looks acceptable. The words are all there and in the right order and properly aligned to the same side, it's just slightly undesirable wrapping which I think is fine in this instance as there's no real chance of introducing confusion between differences like
publication date: 5th May 2022
and

publication date:
5th May 2022

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxgds Older/newer mean the browser version, but based on what you said, I understand the way it looks like in older browsers is acceptable.

@jon-kirwan I've updated the code to use inline-start.

@unoduetre unoduetre force-pushed the 3214-fix-how-arabic-translation-is-structured-on-metadata branch from 77fa6f5 to 7e2ad75 Compare January 31, 2025 10:01
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 31, 2025 10:01 Inactive
padding-right: govuk-spacing(1);
float: inline-start;
clear: inline-start;
padding-inline-start: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @unoduetre. Just one final comment - are clear: inline-start; and padding-inline-start: 0; needed? I tested in a few browsers, and disabling them didn’t seem to have much effect. It might be we can remove both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's better to leave padding-inline-start to make sure the correct padding is set and not set through cascading. But I think clear can indeed be removed. I'll do that in a minute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clear has been removed.

@unoduetre unoduetre force-pushed the 3214-fix-how-arabic-translation-is-structured-on-metadata branch from 7e2ad75 to 87da79f Compare January 31, 2025 16:02
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 31, 2025 16:02 Inactive
Copy link
Contributor

@jon-kirwan jon-kirwan left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. All looks good to me

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4596 January 31, 2025 16:11 Inactive
@unoduetre unoduetre merged commit e944555 into main Jan 31, 2025
12 checks passed
@unoduetre unoduetre deleted the 3214-fix-how-arabic-translation-is-structured-on-metadata branch January 31, 2025 16:14
unoduetre added a commit that referenced this pull request Jan 31, 2025
* Fix RTL support in metadata component ([PR #4596](#4596))
@unoduetre unoduetre mentioned this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants