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

Wrong order of "lineHeights" in line height drop-down #4846

Open
earshinov opened this issue Nov 30, 2024 · 2 comments
Open

Wrong order of "lineHeights" in line height drop-down #4846

earshinov opened this issue Nov 30, 2024 · 2 comments

Comments

@earshinov
Copy link

earshinov commented Nov 30, 2024

Copied from #4143, which was closed and not reopened


Expected behavior.

Line heights in the drop-down should have the same order as in the lineHeights options/configuration. Example:

lineHeights: {
      '1': 1,
      '1.15': 1.15,
      '1.5': 1.5,
      '2':  2,
      '3': 3
    }

Should be shown as 1, 1.15, 1.5, 2, 3 in the drop-down. I'd suggest to change the configuration and use an array instead, like:

lineHeights: [
  {label: '1', value: 1},
  {label: '1.15', value: 1.15},
  {label: '1.5', value: 1.5},
  {label: '2', value: 2},
  {label: '3', value: 3},
]

This could be easily implemented with backward-compatibility by checking the type of the lineHeights property. If it is an Array, use the new order defined by the array. If it is a plain object use the existing for/in loop.

Actual behavior.

Instead, the drop-down shows the line heights in this order: 1, 2, 3, 1.15, 1.5 - The entries in the drop-down are sorted by the natural order of map elements in JavaScript. The order defined by the programmer is ignored.

image

Steps to reproduce the problem.

Simply use the configuration from "Expected behavior".

Editor version.

3.2.3

OS.

Windows 10

Browser.

All browsers

@earshinov
Copy link
Author

Fresh repro from comment


@ilyaskarim , https://jsfiddle.net/urfzbe1t/:

lineHeights: {
  '1': 1,
  '1.15': 1.15,
  '1.5': 1.5,
  '2':  2,
  '3': 3
}

image

Froala v4.3.0

@ilyaskarim
Copy link

Fresh repro from comment

@ilyaskarim , https://jsfiddle.net/urfzbe1t/:

lineHeights: {
  '1': 1,
  '1.15': 1.15,
  '1.5': 1.5,
  '2':  2,
  '3': 3
}

image

Froala v4.3.0

Thank you for sharing the additional details @earshinov. I have submitted this issue internally for further review from the dev-team.

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

No branches or pull requests

2 participants