Skip to content

fix(material/list): use theme spacing for leading icons in RTL - #34080

Open
Ahmed7991 wants to merge 1 commit into
angular:mainfrom
Ahmed7991:list-rtl-leading-icon-tokens
Open

Ahmed7991 wants to merge 1 commit into
angular:mainfrom
Ahmed7991:list-rtl-leading-icon-tokens

Conversation

@Ahmed7991

Copy link
Copy Markdown

In RTL, the leading icon of a list item had its margins hardcoded to 32px and 16px, instead of using the leading-icon-start-space and leading-icon-end-space tokens like in LTR. The rule has to use physical properties, because icon font stylesheets (e.g. Material Icons/Symbols) set direction: ltr on the icon, which makes the logical margins resolve as LTR inside an RTL list. With the M2 values (16px/32px) this happened to look correct, but with M3 (16px/16px, smaller with density) the gap between the icon and the text was twice as large in RTL.

These changes swap the token values in the RTL rule instead of hardcoding them, so RTL mirrors LTR for any theme.

Measured in an Angular 22.2 / Material 22.2.6 app (Chromium and Firefox), edge → icon / icon → text:

Tokens LTR RTL before RTL after
M3 default (16/16) 16 / 16 16 / 32 16 / 16
M3 density -2 (8/8) 8 / 8 16 / 32 8 / 8
M2 (16/32) 16 / 32 16 / 32 16 / 32

Fixes #30537.

In RTL, the leading icon of a list item had its margins hardcoded to `32px` and `16px`, instead of using the `leading-icon-start-space` and `leading-icon-end-space` tokens like in LTR. The rule has to use physical properties, because icon font stylesheets (e.g. Material Icons/Symbols) set `direction: ltr` on the icon, which makes the logical margins resolve as LTR inside an RTL list. With the M2 values (16px/32px) this happened to look correct, but with M3 (16px/16px, smaller with density) the gap between the icon and the text was twice as large in RTL.

These changes swap the token values in the RTL rule instead of hardcoding them, so RTL mirrors LTR for any theme.

Fixes angular#30537.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(MatList): Icons do not respect RTL direction

1 participant