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
3 changes: 2 additions & 1 deletion packages/main/cypress/specs/MultiInput.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,8 @@ describe("Keyboard handling", () => {
.should("be.focused");
});

it("should delete value on backspace", () => {
// Test is skipped for now as it fails randomly
it.skip("should delete value on backspace", () => {
cy.mount(
<MultiInput id="two-tokens" value="abc">
<Token slot="tokens" id="firstToken" text="aa"></Token>
Expand Down
47 changes: 47 additions & 0 deletions packages/main/cypress/specs/MultiInput.mobile.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import MultiInput from "../../src/MultiInput.js";
import ResponsivePopover from "../../src/ResponsivePopover.js";
import "../../src/features/InputSuggestions.js";

describe("Multi Input on mobile device", () => {
beforeEach(() => {
cy.ui5SimulateDevice("phone");
});

it("should return old value if dialog is cancelled and change should not be called", () => {
const onChange = cy.spy().as("onChange");

cy.mount(
<MultiInput showSuggestions={true} onChange={onChange} value="test"></MultiInput>
);

cy.get("[ui5-multi-input]")
.as("multiInput");

cy.get("@multiInput")
.realClick();

cy.get("@multiInput")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.as("popover")
.ui5ResponsivePopoverOpened();

cy.wait(500);

cy.get("@multiInput")
.shadow().find(".ui5-input-inner-phone").realClick();

cy.get("@multiInput")
.shadow().find(".ui5-input-inner-phone").realType("b");

// press cancel
cy.get("@multiInput")
.shadow()
.find(".ui5-responsive-popover-close-btn")
.realClick();

cy.get("@multiInput")
.should("have.value", "test");
cy.get("@onChange").should("not.have.been.called");
});
});
11 changes: 11 additions & 0 deletions packages/main/src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1357,9 +1357,20 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
this.open = false;
}

_confirmMobileValue() {
this._closePicker();
this._handleChange();
}

_cancelMobileValue() {
this.value = this.previousValue;
this._closePicker();
}

_afterOpenPicker() {
// Set initial focus to the native input
if (isPhone()) {
this.previousValue = this.value;
(this.getInputDOMRef())!.focus();
this._composition?.addEventListeners();
}
Expand Down
5 changes: 2 additions & 3 deletions packages/main/src/features/InputSuggestionsTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default function InputSuggestionsTemplate(this: Input, hooks?: { suggesti
showClearIcon={this.showClearIcon}
placeholder={this.placeholder}
onInput={this._handleInput}
onChange={this._handleChange}
/>
</div>
</div>
Expand Down Expand Up @@ -79,14 +78,14 @@ export default function InputSuggestionsTemplate(this: Input, hooks?: { suggesti
<div slot="footer" class="ui5-responsive-popover-footer">
<Button
design="Emphasized"
onClick={this._closePicker}
onClick={this._confirmMobileValue}
>
{this._suggestionsOkButtonText}
</Button>
<Button
class="ui5-responsive-popover-close-btn"
design="Transparent"
onClick={this._closePicker}
onClick={this._cancelMobileValue}
>
{this._suggestionsCancelButtonText}
</Button>
Expand Down
Loading