Skip to content

Commit 1d377ba

Browse files
authored
refactor(ui5-popover): improve layouting, styling and positioning (#779)
BREAKING CHANGE: stayOpenOnScroll is now removed - Popover will no longer close when the browser is scrolled and its parent (opener) is visible in the viewport.
1 parent 3ccf80e commit 1d377ba

32 files changed

+914
-514
lines changed

packages/base/src/UI5Element.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class UI5Element extends HTMLElement {
470470

471471
const focusDomRef = this.getFocusDomRef();
472472

473-
if (focusDomRef) {
473+
if (focusDomRef && typeof focusDomRef.focus === "function") {
474474
focusDomRef.focus();
475475
}
476476
}

packages/main/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"@wdio/sync": "^5.12.1",
110110
"@webcomponents/webcomponentsjs": "^2.2.7",
111111
"chai": "^4.2.0",
112-
"chromedriver": "^76.0.0",
112+
"chromedriver": "^77.0.0",
113113
"clean-css": "^4.2.1",
114114
"copy-and-watch": "^0.1.2",
115115
"cpx": "^1.5.0",
@@ -153,6 +153,6 @@
153153
"resolutions": {
154154
"abstract-syntax-tree": "1.0.3",
155155
"dir-glob": "2.0.0",
156-
"wdio-chromedriver-service/chromedriver": "^76.0.0"
156+
"wdio-chromedriver-service/chromedriver": "^77.0.0"
157157
}
158158
}

packages/main/src/Input.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<input id="{{_id}}-inner"
1212
class="ui5-input-inner"
1313
type="{{inputType}}"
14+
inner-input
1415
?disabled="{{disabled}}"
1516
?readonly="{{_readonly}}"
1617
?required="{{required}}"

packages/main/src/Input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class Input extends UI5Element {
445445
- value of the host and the internal input should be differnt in case of actual input
446446
- input is called when a key is pressed => keyup should not be called yet
447447
*/
448-
const skipFiring = (this.getInputDOMRef().value === this.value) && isIE() && !this._keyDown && this.placeholder;
448+
const skipFiring = (this.getInputDOMRef().value === this.value) && isIE() && !this._keyDown && !!this.placeholder;
449449

450450
!skipFiring && this.fireEventByAction(this.ACTION_USER_INPUT);
451451

packages/main/src/MultiComboBox.hbs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020

2121
<input id="ui5-multi-combobox-input"
2222
value="{{value}}"
23+
inner-input
2324
placeholder="{{placeholder}}"
2425
?disabled={{disabled}}
2526
?readonly={{readonly}}
2627
value-state="{{valueState}}"
2728
@input="{{_inputLiveChange}}"
2829
@change={{_inputChange}}
29-
@keydown="{{_keydown}}"
30+
@keydown="{{_onkeydown}}"
31+
@keyup="{{_onkeyup}}"
3032
@focusin="{{_focusin}}"
3133
@focusout="{{_focusout}}">
3234
</input>

packages/main/src/MultiComboBox.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
44
import { isShow, isDown, isBackSpace } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js";
55
import "./icons/slim-arrow-down.js";
66
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
7+
import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js";
78
import MultiComboBoxTemplate from "./generated/templates/MultiComboBoxTemplate.lit.js";
89
import Tokenizer from "./Tokenizer.js";
910
import Token from "./Token.js";
@@ -277,7 +278,20 @@ class MultiComboBox extends UI5Element {
277278
const filteredItems = this._filterItems(value);
278279
const oldValueState = this.valueState;
279280

281+
/* skip calling change event when an input with a placeholder is focused on IE
282+
- value of the host and the internal input should be differnt in case of actual input
283+
- input is called when a key is pressed => keyup should not be called yet
284+
*/
285+
const skipFiring = (this._inputDom.value === this.value) && isIE && !this._keyDown && !!this.placeholder;
286+
287+
if (skipFiring) {
288+
event.preventDefault();
289+
290+
return;
291+
}
292+
280293
if (this._validationTimeout) {
294+
input.value = this._inputLastValue;
281295
return;
282296
}
283297

@@ -289,6 +303,7 @@ class MultiComboBox extends UI5Element {
289303
this.valueState = oldValueState;
290304
this._validationTimeout = null;
291305
}, 2000);
306+
292307
return;
293308
}
294309

@@ -330,7 +345,11 @@ class MultiComboBox extends UI5Element {
330345
}
331346
}
332347

333-
_keydown(event) {
348+
_onkeyup() {
349+
this._keyDown = false;
350+
}
351+
352+
_onkeydown(event) {
334353
if (isShow(event) && !this.readonly && !this.disabled) {
335354
event.preventDefault();
336355
this._togglePopover();
@@ -355,6 +374,8 @@ class MultiComboBox extends UI5Element {
355374
this._tokenizer.tokens[lastTokenIndex].focus();
356375
this._tokenizer._itemNav.currentIndex = lastTokenIndex;
357376
}
377+
378+
this._keyDown = true;
358379
}
359380

360381
_filterItems(value) {

packages/main/src/Popover.hbs

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
{{>include "./Popup.hbs"}}
1+
<div class="ui5-popover-root" role="dialog" aria-modal="true" aria-labelledby="ui5-popover-header">
22

3-
<span class="ui5-popup-frame" @focusin="{{onfocusin}}">
4-
<span id="{{_id}}-firstfe" tabindex="0" @focusin={{focusHelper.forwardToLast}}></span>
5-
<div style="{{styles.main}}" role="dialog" aria-modal="true" aria-labelledby="{{headerId}}" tabindex="-1" class="ui5-popup-root ui5-popover-root">
6-
{{> header}}
7-
<div id="{{_id}}-content" style="{{styles.content}}" class="ui5-popup-content">
8-
<div class="ui5-popup-scroll">
9-
<slot></slot>
10-
</div>
11-
</div>
12-
{{> footer}}
13-
<span id="{{_id}}-arrow" style="{{styles.arrow}}" class="ui5-popover-arr"></span>
3+
<span class="ui5-popover-arr" style="{{styles.arrow}}"></span>
4+
5+
{{#if header.length }}
6+
<div class="ui5-popover-header-root" id="ui5-popover-header" role="toolbar">
7+
<slot name="header"></slot>
148
</div>
15-
<span id="{{_id}}-lastfe" tabindex="0" @focusin={{focusHelper.forwardToFirst}}></span>
16-
<div tabindex="0" id="{{_id}}-blocklayer" style="{{styles.blockLayer}}" class="{{classes.blockLayer}}"></div>
17-
</span>
9+
{{else}}
10+
<h2 class="ui5-popup-header-text" id="ui5-popover-header">{{headerText}}</h2>
11+
{{/if}}
12+
13+
<span class="first-fe" tabindex="0" @focusin={{forwardToLast}}></span>
14+
15+
<div class="ui5-popover-content">
16+
<slot></slot>
17+
</div>
18+
19+
<span class="last-fe" tabindex="0" @focusin={{forwardToFirst}}></span>
20+
21+
{{#if footer.length }}
22+
<div class="ui5-popover-footer-root" role="toolbar">
23+
<slot name="footer"></slot>
24+
</div>
25+
{{/if}}
26+
27+
</div>

0 commit comments

Comments
 (0)