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

Forms: fix weird chrome only rendering issue #17654

Conversation

AdrienClairembault
Copy link
Contributor

No idea why this only happens on chrome, I had to inject a display: flex instruction into a specific select2 span for it to work.
Super hacky but I don't understand the issue at all, probably some chrome / select2 conflict.

Before:
image

After:
image

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets

@cconard96
Copy link
Contributor

I don't know why it happens in Chrome, but the issue is the flex styles for the selection template. Why not remove all the classes from the spans and just add a right margin to the icons?

diff --git a/src/Glpi/Form/QuestionType/QuestionTypesManager.php b/src/Glpi/Form/QuestionType/QuestionTypesManager.php
index 63766514e5..1245621d4d 100644
--- a/src/Glpi/Form/QuestionType/QuestionTypesManager.php
+++ b/src/Glpi/Form/QuestionType/QuestionTypesManager.php
@@ -177,8 +177,8 @@ final class QuestionTypesManager
         return <<<JS
             function(item) {
                 const icons = {$js_icons};
-                return $('<span class="d-flex flex-row-reverse align-items-center gap-2">'
-                    + '<i class="' + _.escape(icons[item.id]) + '"></i>'
+                return $('<span>'
+                    + '<i class="' + _.escape(icons[item.id]) + ' me-3"></i>'
                     + _.escape(item.text)
                     + '</span>');
             }
@@ -202,8 +202,8 @@ JS;
         return <<<JS
             function(item) {
                 const icons = {$js_icons};
-                return $('<span class="d-flex align-items-center gap-2">'
-                    + '<i class="' + _.escape(icons[item.id]) + '"></i>'
+                return $('<span>'
+                    + '<i class="' + _.escape(icons[item.id]) + ' me-3"></i>'
                     + _.escape(item.text)
                     + '</span>');
             }

@AdrienClairembault
Copy link
Contributor Author

I don't know why it happens in Chrome, but the issue is the flex styles for the selection template. Why not remove all the classes from the spans and just add a right margin to the icons?

The flex in the icon ensure horizontal alignement with align-items-center.
Sadly without it the icon is misaligned with the text.

@cconard96
Copy link
Contributor

If there is an alignment issue, it isn't noticeable.

@AdrienClairembault AdrienClairembault merged commit 6c4236e into glpi-project:main Aug 12, 2024
7 checks passed
@AdrienClairembault AdrienClairembault deleted the fix/forms/question-type-dropdown-render branch September 19, 2024 08:16
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.

3 participants