Skip to content

Commit 2f173e2

Browse files
authored
Merge branch 'main' into ai-textarea-adjustments
2 parents 9601100 + 6bf7b05 commit 2f173e2

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

packages/base/src/features/OpenUI5Support.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ class OpenUI5Support {
165165
animationMode: config.getAnimationMode(),
166166
language: config.getLanguage(),
167167
theme: config.getTheme(),
168-
themeRoot: config.getThemeRoot(),
168+
themeRoot: typeof config.getThemeRoot === "function" ? config.getThemeRoot() : undefined,
169169
rtl: config.getRTL(),
170-
timezone: config.getTimezone(),
170+
timezone: typeof config.getTimezone === "function" ? config.getTimezone() : undefined,
171171
calendarType: config.getCalendarType(),
172172
formatSettings: {
173173
firstDayOfWeek: LocaleData ? LocaleData.getInstance(config.getLocale()).getFirstDayOfWeek() : undefined,
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
type OpenUI5Patcher = {
2-
prototype: {
3-
_mAttributes: { [key: string]: string },
4-
openEnd: () => OpenUI5Patcher,
5-
}
1+
type PatcherTarget = {
2+
_mAttributes: { [key: string]: string },
3+
openEnd: () => OpenUI5Patcher,
64
};
75

8-
const patchPatcher = (Patcher: OpenUI5Patcher) => {
9-
const origOpenEnd = Patcher.prototype.openEnd;
10-
Patcher.prototype.openEnd = function openEnd() {
11-
if (this._mAttributes.popover) {
6+
type OpenUI5Patcher = { prototype: PatcherTarget } // newer versions (on prototype)
7+
| PatcherTarget; // older versions (on constructor directly)
8+
9+
const patchOpenEnd = (target: PatcherTarget) => {
10+
const origOpenEnd = target.openEnd;
11+
target.openEnd = function openEnd() {
12+
if (this._mAttributes?.popover) {
1213
delete this._mAttributes.popover; // The "popover" attribute will be managed externally, don't let Patcher remove it
1314
}
1415
return origOpenEnd.apply(this);
1516
};
1617
};
1718

19+
const patchPatcher = (Patcher: OpenUI5Patcher) => {
20+
// Newer version: properties are on prototype
21+
if ("prototype" in Patcher && "openEnd" in Patcher.prototype) {
22+
patchOpenEnd(Patcher.prototype);
23+
} else if ("openEnd" in Patcher) {
24+
// Older version: properties are on constructor directly
25+
patchOpenEnd(Patcher);
26+
}
27+
};
28+
1829
export default patchPatcher;
1930
export type { OpenUI5Patcher };

packages/main/cypress/specs/OpenUI5andWebCPopups.cy.tsx

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ import ComboBox from "../../src/ComboBox.js";
77
import ComboBoxItem from "../../src/ComboBoxItem.js";
88
import ResponsivePopover from "../../src/ResponsivePopover.js";
99

10+
let OpenUI5Element;
11+
1012
function onOpenUI5InitMethod(win) {
11-
(win as any).sap.ui.require(["sap/ui/core/HTML", "sap/m/Button", "sap/m/Dialog", "sap/m/Popover", "sap/m/Input"], async (HTML, Button, Dialog, Popover, Input) => {
13+
(win as any).sap.ui.require([
14+
"sap/ui/core/Element",
15+
"sap/ui/core/HTML",
16+
"sap/m/Button",
17+
"sap/m/Dialog",
18+
"sap/m/Popover",
19+
"sap/m/Input"
20+
], async (Element, HTML, Button, Dialog, Popover, Input) => {
1221

1322
await OpenUI5Support.init();
14-
23+
OpenUI5Element = Element;
1524
new Button("openUI5Button", {
1625
text: "Open OpenUI5 Dialog",
1726
press: function () {
@@ -21,7 +30,7 @@ function onOpenUI5InitMethod(win) {
2130
content: [
2231
new HTML({
2332
content:
24-
`<ui5-select id="webCSelect1">
33+
`<ui5-select id="webCSelect1">
2534
<ui5-option>Option 1</ui5-option>
2635
<ui5-option>Option 2</ui5-option>
2736
<ui5-option>Option 3</ui5-option>
@@ -206,6 +215,15 @@ function openUI5Popover(win, opener) {
206215
});
207216
}
208217

218+
function isOpenUI5DialogOpen($dialog) {
219+
expect(OpenUI5Element).to.exist;
220+
221+
const dialogInstance = OpenUI5Element.getElementById($dialog.attr("id"));
222+
223+
expect(dialogInstance).to.exist
224+
expect(dialogInstance.isOpen()).to.be.true;
225+
};
226+
209227
describe("ui5 and web components integration", () => {
210228
beforeEach(() => {
211229
// mount the components
@@ -480,6 +498,10 @@ describe("ui5 and web components integration", () => {
480498
.find('input')
481499
.focus();
482500

501+
cy.get("#openUI5Combobox1")
502+
.find('input')
503+
.should('be.focused');
504+
483505
cy.realPress("Escape");
484506

485507
cy.get('#dialog1')
@@ -518,12 +540,11 @@ describe("ui5 and web components integration", () => {
518540
.should('be.visible')
519541
.realClick();
520542

521-
cy.get<Dialog>("#respPopover").ui5DialogOpened();
543+
cy.get<ResponsivePopover>("#respPopover").ui5ResponsivePopoverOpened();
522544

523545
cy.realPress("Escape");
524546

525-
cy.get("#respPopover")
526-
.should('not.be.visible');
547+
cy.get<ResponsivePopover>("#respPopover").ui5ResponsivePopoverClosed();
527548

528549
cy.get("#openUI5Dialog1")
529550
.should('be.visible');
@@ -549,12 +570,12 @@ describe("ui5 and web components integration", () => {
549570
.should('be.visible')
550571
.realClick();
551572

552-
cy.get<Dialog>("#respPopoverNoInitialFocus").ui5DialogOpened();
573+
cy.get<ResponsivePopover>("#respPopoverNoInitialFocus").ui5ResponsivePopoverOpened();
553574

554575
cy.realPress("Escape");
555576

556-
cy.get("#respPopoverNoInitialFocus")
557-
.should('not.be.visible');
577+
cy.get<ResponsivePopover>("#respPopoverNoInitialFocus")
578+
.ui5ResponsivePopoverClosed();
558579

559580
cy.get("#openResPopoverNoInitialFocusButton")
560581
.should('be.focused');
@@ -591,8 +612,8 @@ describe("ui5 and web components integration", () => {
591612

592613
cy.get("#webCSelect1")
593614
.shadow()
594-
.find("[ui5-responsive-popover]")
595-
.should('not.be.visible');
615+
.find<ResponsivePopover>("[ui5-responsive-popover]")
616+
.ui5ResponsivePopoverClosed();
596617

597618
cy.get("#openUI5Dialog1")
598619
.should('be.visible');
@@ -631,8 +652,8 @@ describe("ui5 and web components integration", () => {
631652

632653
cy.get("#webCComboBox1")
633654
.shadow()
634-
.find("[ui5-responsive-popover]")
635-
.should('not.be.visible');
655+
.find<ResponsivePopover>("[ui5-responsive-popover]")
656+
.ui5ResponsivePopoverClosed();
636657

637658
cy.get("#openUI5Dialog1")
638659
.should('be.visible');
@@ -688,7 +709,9 @@ describe("ui5 and web components integration", () => {
688709
.realClick();
689710

690711
cy.get("#openUI5DialogFinal")
691-
.should('be.visible');
712+
.should('be.visible')
713+
.should(isOpenUI5DialogOpen);
714+
cy.wait(1000);
692715

693716
cy.get("#openUI5Dialog1")
694717
.should('not.be.visible');
@@ -706,7 +729,9 @@ describe("ui5 and web components integration", () => {
706729
.should('not.exist');
707730

708731
cy.get("#openUI5DialogWithButtons")
709-
.should('be.visible');
732+
.should('be.visible')
733+
.should(isOpenUI5DialogOpen);
734+
cy.wait(100);
710735

711736
cy.realPress("Escape");
712737

packages/main/src/themes/Token.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
background: var(--sapButton_Hover_Background);
2121
}
2222

23-
:host([selected]) {
23+
:host(:not([readonly])[selected]) {
2424
background: var(--sapButton_Selected_Background);
2525
border: var(--sapButton_BorderWidth) solid var(--sapButton_Selected_BorderColor);
2626
color: var(--sapButton_Selected_TextColor);
2727
}
2828

29-
:host([selected]) .ui5-token--wrapper::before {
29+
:host(:not([readonly])[selected]) .ui5-token--wrapper::before {
3030
content: "";
3131
position: absolute;
3232
border-bottom: var(--_ui5_token_selected_internal_border_bottom);
@@ -40,6 +40,11 @@
4040
pointer-events: none;
4141
}
4242

43+
:host([readonly][selected]) .ui5-token--text {
44+
background: var(--sapSelectedColor);
45+
color: var(--sapContent_ContrastTextColor);
46+
}
47+
4348
:host([selected]:hover) {
4449
background: var(--sapButton_Selected_Hover_Background);
4550
}
@@ -58,7 +63,7 @@
5863
outline: var(--_ui5_token_selected_focus_outline);
5964
}
6065

61-
:host([focused][selected]:not(:hover)) {
66+
:host(:not([readonly])[focused][selected]:not(:hover)) {
6267
background: var(--sapButton_Selected_Background);
6368
color: var(--sapButton_Selected_TextColor);
6469
border: var(--_ui5_token_focused_selected_border);

0 commit comments

Comments
 (0)