Skip to content

Commit df9a5da

Browse files
authored
fix(ui5-step-input): adjust z-index and fix focus issues (#13391)
There was incorrect z-index positioning of [ - ] button of the `ui5-step-input` component and as a result when there is some sticky element on page with z-index: 1, and a StepInput goes under it, the [ - ] button's icon appears over this sticky element: <img width="779" height="392" alt="image" src="https://github.com/user-attachments/assets/6b114923-15ca-46b9-aaaa-a93a2e4e912c" /> After fixing this issue, other focus-related issues appeared, and are also fixed by this PR. Fixes: #7709
1 parent 00afa74 commit df9a5da

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/main/src/StepInput.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class StepInput extends UI5Element implements IFormInputElement {
483483

484484
_onButtonFocusOut() {
485485
setTimeout(() => {
486-
if (!this._inputFocused) {
486+
if (!this._inputFocused && !this.shadowRoot!.activeElement) {
487487
this.inputOuter.removeAttribute("focused");
488488
}
489489
}, 0);
@@ -507,13 +507,11 @@ class StepInput extends UI5Element implements IFormInputElement {
507507
}
508508

509509
_onMouseWheel(e: WheelEvent) {
510-
if (this.disabled || this.readonly) {
510+
if (this.disabled || this.readonly || !this._isFocused) {
511511
return;
512512
}
513513

514-
if (this._isFocused) {
515-
e.preventDefault();
516-
}
514+
e.preventDefault();
517515

518516
const isScrollUp = e.deltaY < 0;
519517
const modifier = isScrollUp ? this.step : -this.step;
@@ -767,15 +765,25 @@ class StepInput extends UI5Element implements IFormInputElement {
767765
return !Number.isNaN(parsedValue) && !/, {2,}/.test(typedValue);
768766
}
769767

770-
_decSpin() {
768+
_decSpin(e: MouseEvent) {
769+
if (this._isFocused || this._decIconDisabled) {
770+
e.preventDefault();
771+
}
771772
if (!this._decIconDisabled) {
772773
this._spinValue(false, true);
774+
} else {
775+
this.input.focus();
773776
}
774777
}
775778

776-
_incSpin() {
779+
_incSpin(e: MouseEvent) {
780+
if (this._isFocused || this._incIconDisabled) {
781+
e.preventDefault();
782+
}
777783
if (!this._incIconDisabled) {
778784
this._spinValue(true, true);
785+
} else {
786+
this.input.focus();
779787
}
780788
}
781789

packages/main/src/themes/StepInput.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
box-sizing: border-box;
1919
height: var(--_ui5_input_height);
2020
position: relative;
21+
isolation: isolate;
2122
margin: var(--_ui5_input_margin_top_bottom) 0;
2223
min-width: var(--_ui5_step_input_min_width);
2324
text-align: right;
@@ -99,7 +100,7 @@
99100
pointer-events: none;
100101
border-radius: var(--sapField_BorderCornerRadius);
101102
border-style: var(--_ui5_input_error_warning_border_style);
102-
z-index: 1;
103+
z-index: 0;
103104
border-width: 0px;
104105
}
105106

0 commit comments

Comments
 (0)