Open Leland opened 4 years ago
Hi @Leland. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.3-develop instance
- upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@Leland do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
@magento give me 2.3-develop instance
Hi @Leland. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @Leland, here is your Magento instance.
Admin access: https://i-25592-2-3-develop.instances.magento-community.engineering/admin
Login: admin
Password: 123123q
Instance will be terminated in up to 3 hours.
Hi @engcom-Charlie. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-23200
were created
Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
I've just checked the issue and according to the docs of .lib-line-height the conversion to rem
is there by design, which is even outlined in the example provided.
@krzksz respectfully, I'm not sure you understand the issue. This issue is not with lib-line-height()
specifically.
See the title: "@font-size-unit-convert affects unitless values." lib-line-height()
happens to be a function which has errors because of the issues in the unit conversion plumbing underneath: unitless values are a standard part of CSS, and Magento's internal mixins do not support them.
@button__line-height: 1
will cause a theme based on default blank or Luma to output 0.1rem
, which you hopefully can agree is an issue - documentation to the opposite notwithstanding.
Regardless, those docs are not actually correct - not only is there no fallback to px
, calculates line-height in **rem**
is not accurate either. lib-line-height()
converts to whatever @font-size-unit
is set to - that could be rem, or em, or any other CSS unit supported by LESS.
Hey @Leland, thanks for the clarification, I totally understand that unitless values are completely valid for line-height
according to CSS specification and I would really like Magento to support them.
That said, I've already tried a lot of different variations and changes to .lib-line-height
which resulted in:
// Rem line height
.lib-line-height(@heightValue) when (isnumber(@heightValue)) and not (ispercentage(@heightValue)) and not (get-unit(@heightValue) = ~'') {
.lib-font-size-value(@heightValue);
.lib-css(line-height, @fontValue);
}
.lib-line-height(@heightValue) when (ispercentage(@heightValue)), (isnumber(@heightValue)) and (get-unit(@heightValue) = ~'') {
.lib-css(line-height, @heightValue);
}
there are two problems with this (and all of the other that I tried) solution:
false
is passed as an argument, compiling fails with:
error evaluating function `get-unit` Notice: Undefined property: Less_Tree_Keyword::$unit
Since I'm quite out of ideas how to solve it from the code perspective (maybe some other way will enlighten me), I'm planning so file a separate issue that outlines this problem with a parser so we can proceed our work here.
:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-29004
were created
Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
@Leland if it's only affected in line height case why not use native property instead mixins. You can controll value you want Some case you don't want convert to rem you can set @font-size-unit-convert: false; in top of customises less
Just curiousity how this @font-size-unit-convert can affect to other property if use unitless
why not use native property instead mixins
Setting global button line-heights to 1
is a very common use case here, as outlined above. On a default instance of Luma, that would produce an output of 0.1rem. That's clearly not intended or correct output one way or another, and we can't expect developers to look at that 0.1rem and think "oh, I should just be using properties, not the mixin!"
We should definitely support unitless values on this IMO.
At absolute worst, we could just have functions die on unitless input. I don't support that approach, but it would at least be an explicit one.
ok i see plenty usage line-height around button here. Undoubtedly we need refactor to work with unitless
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.
This is still important to me.
Preconditions (*)
Magento v2.3.1 & 2.3-develop
Steps to reproduce (*)
Compile this LESS under either blank or Luma:
Expected result (*)
Actual result (*)
This is the underlying mixin powering many, many lib- mixins across the site, for instance
lib-button()
, and thus this issue pertains to e.g@button__line-height: 1;
.As you follow the issue, you realize this is systemic in the way the plumbing for these mixins operates:
https://github.com/magento/magento2/blob/54742d5150fa97d08defd89226ddf5cc87aefa85/lib/web/css/source/lib/_utilities.less#L14-L23
@font-size-unit
is defaulted torem
, and thus the mixin will always convert to this, even if it's not needed. I'll note that this behavior is disabled when@font-size-unit-convert: false
, though this is not the default under either blank or Luma.A simple fix would be to add a guard clause utilizing LESS' built-in
get-unit()
function, which returns falsey if the value passed is unitless.