Skip to content

Commit 7549ae6

Browse files
IcelandWarriorGerrit Code Review
authored andcommitted
Merge "[FIX] We've now fixed a jump issue in the header container by using an outline instead of a border" into rel-1.145
2 parents 141c3aa + c780e78 commit 7549ae6

File tree

2 files changed

+99
-4
lines changed

2 files changed

+99
-4
lines changed

src/sap.m/src/sap/m/themes/base/HeaderContainer.less

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,11 @@ html.sap-tablet:not(.sap-desktop) .sapMHrdrBottomPadding .sapMHdrCntrCntr.Vertic
282282
}
283283

284284
html.sap-desktop .sapMHrdrCntrInner:focus {
285-
outline: none;
286-
border: var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);
285+
outline: none;
286+
}
287+
html.sap-desktop .sapMHrdrCntrInner:focus-visible {
288+
outline: var(--sapContent_FocusWidth) var(--sapContent_FocusStyle) var(--sapContent_FocusColor);
289+
outline-offset: -2px;
287290
}
288291

289292
@media (min-width:320px) and (max-width:599px) {

src/sap.m/test/sap/m/qunit/HeaderContainer.qunit.js

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ sap.ui.define([
1919
"sap/ui/core/Core",
2020
"sap/m/Panel",
2121
"sap/m/GenericTile",
22-
"sap/ui/qunit/utils/nextUIUpdate"
23-
], function(Localization, Element, jQuery, HeaderContainer, FlexBox, Label, VerticalLayout, Button, Device, Icon, coreLibrary, PseudoEvents, Mobile, mobileLibrary, Log, Text, oCore, Panel, GenericTile, nextUIUpdate) {
22+
"sap/ui/qunit/utils/nextUIUpdate",
23+
"sap/ui/qunit/QUnitUtils",
24+
"sap/ui/events/KeyCodes",
25+
"sap/ui/core/theming/Parameters"
26+
], function(Localization, Element, jQuery, HeaderContainer, FlexBox, Label, VerticalLayout, Button, Device, Icon, coreLibrary, PseudoEvents, Mobile, mobileLibrary, Log, Text, oCore, Panel, GenericTile, nextUIUpdate, qutils, KeyCodes, Parameters) {
2427
"use strict";
2528

2629
// shortcut for sap.m.BackgroundDesign
@@ -32,6 +35,23 @@ sap.ui.define([
3235
// shortcut for sap.m.ScreenSizes
3336
var ScreenSizes = mobileLibrary.ScreenSizes;
3437

38+
function remToPx(remValue) {
39+
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
40+
return parseFloat(remValue) * fontSize + "px";
41+
}
42+
function hexToRgb(hex) {
43+
var result = /^#?([a-f\d]{1,2})([a-f\d]{1,2})([a-f\d]{1,2})$/i.exec(hex);
44+
var clr = result ? {
45+
r: parseInt(result[1].length === 1 ? result[1] + result[1] : result[1], 16),
46+
g: parseInt(result[2].length === 1 ? result[2] + result[2] : result[2], 16),
47+
b: parseInt(result[3].length === 1 ? result[3] + result[3] : result[3], 16)
48+
} : null;
49+
if (clr) {
50+
return "rgb(" + clr.r + ", " + clr.g + ", " + clr.b + ")";
51+
}
52+
return hex;
53+
}
54+
3555
Mobile.init();
3656

3757
QUnit.module("Default Property Values", {
@@ -613,6 +633,78 @@ sap.ui.define([
613633
assert.equal(this.oHeaderContainer._oItemNavigation.getItemDomRefs()[0].style["border-color"], "transparent", "Headercontainer border is transparent.");
614634
});
615635

636+
QUnit.module("HeaderContainer :focus-visible outline", {
637+
beforeEach: async function () {
638+
document.documentElement.classList.add("sap-desktop");
639+
this.oHeaderContainer = new HeaderContainer({
640+
content: [
641+
new VerticalLayout(),
642+
new VerticalLayout(),
643+
new VerticalLayout()
644+
]
645+
});
646+
this.oHeaderContainer.placeAt("qunit-fixture");
647+
await nextUIUpdate();
648+
},
649+
afterEach: function () {
650+
document.documentElement.classList.remove("sap-desktop");
651+
this.oHeaderContainer.destroy();
652+
this.oHeaderContainer = null;
653+
}
654+
});
655+
656+
QUnit.test("Checks Outline width, style, color and offset are correct", async function (assert) {
657+
const oInnerDomRef = this.oHeaderContainer.$()
658+
.find(".sapMHrdrCntrInner")[0];
659+
assert.ok(oInnerDomRef, "Inner container exists");
660+
661+
// Helper to get Parameters asynchronously
662+
function getParameterAsync(key, oElement) {
663+
return new Promise((resolve) => {
664+
const value = Parameters.get({
665+
name: key,
666+
scopeElement: oElement,
667+
callback: resolve
668+
});
669+
if (value !== undefined) {
670+
resolve(value);
671+
}
672+
});
673+
}
674+
675+
// Trigger keyboard mode and focus the element
676+
qutils.triggerKeydown(document, KeyCodes.TAB);
677+
oInnerDomRef.focus();
678+
await nextUIUpdate();
679+
680+
// Fetch all theme parameters asynchronously
681+
const expectedWidth = remToPx(await getParameterAsync("sapContent_FocusWidth", oInnerDomRef));
682+
const expectedStyle = await getParameterAsync("sapContent_FocusStyle", oInnerDomRef);
683+
const expectedColor = hexToRgb(await getParameterAsync("sapContent_FocusColor", oInnerDomRef));
684+
685+
const computedStyle = window.getComputedStyle(oInnerDomRef);
686+
687+
assert.strictEqual(
688+
computedStyle.outlineWidth,
689+
expectedWidth,
690+
`Outline width matches theme parameter (expected: ${expectedWidth}, actual: ${computedStyle.outlineWidth})`
691+
);
692+
assert.strictEqual(
693+
computedStyle.outlineStyle,
694+
expectedStyle,
695+
`Outline style matches theme parameter (expected: ${expectedStyle}, actual: ${computedStyle.outlineStyle})`
696+
);
697+
assert.strictEqual(
698+
computedStyle.outlineColor,
699+
expectedColor,
700+
`Outline color matches theme parameter (expected: ${expectedColor}, actual: ${computedStyle.outlineColor})`
701+
);
702+
assert.strictEqual(
703+
computedStyle.outlineOffset,
704+
"-2px",
705+
`Outline offset is -2px (expected: -2px, actual: ${computedStyle.outlineOffset})`
706+
);
707+
});
616708
} //End of Device.system.desktop
617709

618710
QUnit.module("Padding removed when scrolling to begin and end", {

0 commit comments

Comments
 (0)