[BUGFIX] Do not show dropdown arrow if maxItems=1 26/49726/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 1 Sep 2016 08:51:20 +0000 (10:51 +0200)
committerFrans Saris <franssaris@gmail.com>
Thu, 1 Sep 2016 17:26:26 +0000 (19:26 +0200)
A new CSS class is introduced to disable the dropdown arrow for select
boxes if a select box can only contain one item.

Resolves: #77665
Releases: master, 7.6
Change-Id: I095070e833a02728c9d2edd91a33919c0fbaf749
Reviewed-on: https://review.typo3.org/49726
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Build/Resources/Public/Less/TYPO3/_main_form.less
typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
typo3/sysext/t3skin/Resources/Public/Css/backend.css

index 8e5d6f6..e997567 100644 (file)
@@ -166,16 +166,19 @@ select {
                &[size="1"],
                &:not([size]) {
                        appearance: none;
-                       background-image: url('@{path-sysext}/core/Resources/Public/Icons/T3Icons/actions/actions-view-list-expand.svg');
-                       background-position: right 4px center;
-                       background-repeat: no-repeat;
-                       background-size: 16px 16px;
-                       padding-right: 24px;
 
                        &::-ms-expand {
                                display: none;
                        }
 
+                       &:not(.form-select-no-siblings) {
+                               background-image: url('@{path-sysext}/core/Resources/Public/Icons/T3Icons/actions/actions-view-list-expand.svg');
+                               background-position: right 4px center;
+                               background-repeat: no-repeat;
+                               background-size: 16px 16px;
+                               padding-right: 24px;
+                       }
+
                        &.input-sm,
                        .form-group-sm & {
                                line-height: 16px;
index 2ffeaea..0ee23b8 100644 (file)
@@ -539,9 +539,15 @@ abstract class AbstractFormElement extends AbstractNode
             ? MathUtility::forceIntegerInRange($itemArrayC + 1, MathUtility::forceIntegerInRange($params['size'], 1), $params['autoSizeMax'])
             : $params['size'];
         if (!$selector) {
-            $isMultiple = $params['maxitems'] != 1 && $params['size'] != 1;
+            $maxItems = isset($params['maxitems']) ? (int)$params['maxitems'] : 0;
+            $size = isset($params['size']) ? (int)$params['size'] : 0;
+            $classes = ['form-control', 'tceforms-multiselect'];
+            if ($maxItems === 1) {
+                $classes[] = 'form-select-no-siblings';
+            }
+            $isMultiple = $maxItems !== 1 && $size !== 1;
             $selector = '<select id="' . StringUtility::getUniqueId('tceforms-multiselect-') . '" '
-                . ($params['noList'] ? 'style="display: none"' : 'size="' . $sSize . '" class="form-control tceforms-multiselect"')
+                . ($params['noList'] ? 'style="display: none"' : 'size="' . $sSize . '" class="' . implode(' ', $classes) . '"')
                 . ($isMultiple ? ' multiple="multiple"' : '')
                 . ' data-formengine-input-name="' . htmlspecialchars($fName) . '" ' . $this->getValidationDataAsDataAttribute($config) . $onFocus . $params['style'] . $disabled . '>' . implode('', $opt)
                 . '</select>';
index d3ae1e5..8f8ab32 100644 (file)
@@ -12158,16 +12158,19 @@ select.form-control:not([size]) {
   -webkit-appearance: none;
      -moz-appearance: none;
           appearance: none;
+}
+select.form-control[size="1"]::-ms-expand,
+select.form-control:not([size])::-ms-expand {
+  display: none;
+}
+select.form-control[size="1"]:not(.form-select-no-siblings),
+select.form-control:not([size]):not(.form-select-no-siblings) {
   background-image: url('../../../../../../typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-view-list-expand.svg');
   background-position: right 4px center;
   background-repeat: no-repeat;
   background-size: 16px 16px;
   padding-right: 24px;
 }
-select.form-control[size="1"]::-ms-expand,
-select.form-control:not([size])::-ms-expand {
-  display: none;
-}
 select.form-control[size="1"].input-sm,
 select.form-control:not([size]).input-sm,
 .form-group-sm select.form-control[size="1"],