Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions packages/main/src/SliderTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import SliderTooltipCss from "./generated/themes/SliderTooltip.css.js";
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
import { isEnter, isF2, isTabNext } from "@ui5/webcomponents-base/dist/Keys.js";
import type Input from "./Input.js";

Check failure on line 10 in packages/main/src/SliderTooltip.ts

View workflow job for this annotation

GitHub Actions / check

'Input' is defined but never used

import {
SLIDER_TOOLTIP_INPUT_LABEL,
Expand Down Expand Up @@ -44,8 +44,20 @@
"forward-focus": void
};

// _innerValue is set when the user types in the input field, but if an API value is set, it should be ignored
@property({ noAttribute: true })
_innerValue?: string;

private _value?: string;

@property()
value?: string;
set value(val: string | undefined) {
this._innerValue = undefined;
this._value = val;
}
get value() {
return this._value;
}

@property()
inputValue?: string;
Expand Down Expand Up @@ -93,6 +105,7 @@
this.repositionTooltip();
this.attachGlobalScrollHandler();
} else {
this._innerValue = undefined;
this.hidePopover();
this.detachGlobalScrollHandler();
}
Expand Down Expand Up @@ -136,27 +149,26 @@
if (isF2(e) || isTabNext(e)) {
e.preventDefault();

if (!this.isValueValid(this.inputRef.value)) {
const value = this.value;
this.inputRef.value = value || "";
if (!this.isValueValid(this._innerValue ?? "")) {
this._innerValue = undefined;
}

this.valueState = ValueState.None;

this.fireDecoratorEvent("change", { value: this.inputRef.value });
this.fireDecoratorEvent("change", { value: this._innerValue ?? "" });
this.fireDecoratorEvent("forward-focus");
}

if (isEnter(e)) {
if (!this.isValueValid(this.inputRef.value)) {
if (!this.isValueValid(this._innerValue ?? "")) {
this.valueState = ValueState.Negative;

return;
}

this.valueState = ValueState.None;

this.fireDecoratorEvent("change", { value: this.inputRef.value });
this.fireDecoratorEvent("change", { value: this._innerValue ?? "" });
}
}

Expand All @@ -168,9 +180,8 @@
}

_onInputFocusOut(e: FocusEvent) {
if (!this.isValueValid(this.inputRef.value)) {
const value = this.value;
this.inputRef.value = value || "";
if (!this.isValueValid(this._innerValue ?? "")) {
this._innerValue = undefined;
}

const relatedTarget = e.relatedTarget as HTMLElement;
Expand All @@ -180,10 +191,6 @@
}
}

get inputRef() {
return this.shadowRoot?.querySelector("ui5-input") as Input;
}

get _ariaLabelledByInputText() {
return SliderTooltip.i18nBundle.getText(SLIDER_TOOLTIP_INPUT_LABEL);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/main/src/SliderTooltipTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<div class="ui5-slider-tooltip-root">
{this.editable ?
<Input
value={this.value}
value={this._innerValue ?? this.value}
type="Number"
accessibleNameRef="ui5-slider-InputLabel"
onInput={ e => { this._innerValue = e.currentTarget.value } }

Check failure on line 12 in packages/main/src/SliderTooltipTemplate.tsx

View workflow job for this annotation

GitHub Actions / check

Missing semicolon
onKeyDown={this._keydown}
onFocusIn={this._onInputFocusin}
onFocusOut={this._onInputFocusOut}
Expand Down
Loading