Skip to content

Instantly share code, notes, and snippets.

@xTCry
Created February 12, 2023 23:56
Show Gist options
  • Save xTCry/0367e18294c4a97bccd147c41e17a860 to your computer and use it in GitHub Desktop.
Save xTCry/0367e18294c4a97bccd147c41e17a860 to your computer and use it in GitHub Desktop.
[Bitrix] fix(style): Фикс (для админки) отображения выделенных опций при отсутствии фокуса в инпуте `select`

[Bitrix] fix(style)

Фикс (для админки) отображения выделенных опций при отсутствии фокуса в инпуте select

Добавить код, например, в php_interface/init.php

// * Фикс подсветки выделения в input типа 'список' для некоторых браузеров
AddEventHandler('main', 'OnBeforeProlog', 'OnFixAdminStyleInputSelect');
function OnFixAdminStyleInputSelect()
{
    global $APPLICATION;
    /** @var \CMain $APPLICATION */
    
    // Можно внедрить и на другие страницы
    if (strpos($APPLICATION->GetCurPage(), '/bitrix/admin/') === 0) {
        $code = "<style>
        select option:focus,
        select option:active,
        select option:checked {
            background: linear-gradient(#4fe75a, #5ccba2);
            background-color: #4fe75a !important; /* for IE */
        }
        </style>";
        $location = \Bitrix\Main\Page\Asset::getLocationByName(\Bitrix\Main\Page\AssetLocation::AFTER_CSS);
        $oAsset = \Bitrix\Main\Page\Asset::getInstance();
        $oAsset->addString($code, false, $location);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment