Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make input-based components open dialog on mobile device #1144

Merged
merged 38 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1e1f30c
WIP(ui5-responsive-popover): initial implementation
dimovpetar Jan 17, 2020
cc6bd0e
move footer buttons to ui5-responsive-popover and reveal them through…
dimovpetar Jan 17, 2020
7e06462
make MultiComboBox use ResponsivePopover
dimovpetar Jan 20, 2020
28f21d7
Make DatePicker use ResponsivePopover
dimovpetar Jan 20, 2020
81641dc
fix Input suggestion selection on desktop
dimovpetar Jan 21, 2020
b345edb
make header title "Select" translatable text
dimovpetar Jan 21, 2020
30b0311
fix Calendar cells' width on mobile
dimovpetar Jan 22, 2020
6d1ba1a
delete ResponsivePopover.html
dimovpetar Jan 22, 2020
1678228
add ui5-combobox to InputAlignments.html
dimovpetar Jan 22, 2020
9955cab
make all inputs open dialog on click event on mobile
dimovpetar Jan 22, 2020
1333f6a
fix MultiComboBox closing when when there is no matching value on mobile
dimovpetar Jan 22, 2020
f5dba51
make TabContainer use ResponsivePopover
dimovpetar Jan 22, 2020
e34d8c2
fix eslint errors
dimovpetar Jan 22, 2020
4ee74f1
make ResponsivePopover get styles of Popover child
dimovpetar Jan 23, 2020
f004aa0
Merge branch 'master' of github.com:SAP/ui5-webcomponents into respon…
dimovpetar Jan 24, 2020
78f24b9
fix issues with ResponsivePopover after moving to static area
dimovpetar Jan 27, 2020
139683c
extract needed input styles for mobile devices into single file
dimovpetar Jan 27, 2020
201f636
rename InputInPopover.css to ResponsivePopoverInput.css
dimovpetar Jan 27, 2020
974172c
Merge branch 'master' of github.com:SAP/ui5-webcomponents into respon…
dimovpetar Jan 28, 2020
3984d1c
ui5-combobox, ui5-multicombobox - improved initial focus on mobile de…
dimovpetar Jan 28, 2020
a7cc29a
fix ui5-multi-combobox suggestions' down state
dimovpetar Jan 28, 2020
e6fb842
remove workaround for ui5-input and fix selection behavior
dimovpetar Jan 28, 2020
a13f425
return workaround for ui5-input on focus out
dimovpetar Jan 29, 2020
f115505
remove unneeded styles and attributes for input on mobile
dimovpetar Jan 29, 2020
f315d6c
blur inputs on mobile devices after dialog close
dimovpetar Jan 29, 2020
4c18d48
make ResponsivePopover extend Popover
dimovpetar Jan 29, 2020
90171af
make confirm button type "Transparent"
dimovpetar Jan 29, 2020
8f03d7b
make ui5-datepicker blur after dialog close on mobile
dimovpetar Jan 30, 2020
c36cf4d
make ui5-datepicker blur after dialog close on mobile
dimovpetar Jan 30, 2020
8309bb5
Merge remote-tracking branch 'refs/remotes/origin/responsive_popover'…
dimovpetar Jan 30, 2020
c5c3681
add toggle filtering on ui5-multi-combox on mobile
dimovpetar Jan 30, 2020
12aee11
fix ComboBox autocompletion on phone
dimovpetar Jan 30, 2020
cf56f08
don't open dialog on click if "readonly" is set
dimovpetar Jan 30, 2020
cbf1af3
delete properties from ResponsivePopover and use slots
dimovpetar Jan 31, 2020
9194d67
Merge branch 'master' of github.com:SAP/ui5-webcomponents into respon…
dimovpetar Jan 31, 2020
3cc23fe
resolve problem with StaticArea getter merging
dimovpetar Jan 31, 2020
21add3a
adress comments
dimovpetar Feb 4, 2020
c6a8f70
add comments why "blur" is needed after close
dimovpetar Feb 4, 2020
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
1 change: 1 addition & 0 deletions packages/main/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Link from "./dist/Link.js";
import Popover from "./dist/Popover.js";
import Panel from "./dist/Panel.js";
import RadioButton from "./dist/RadioButton.js";
import ResponsivePopover from "./dist/ResponsivePopover.js";
import Select from "./dist/Select.js";
import Option from "./dist/Option.js";
import Switch from "./dist/Switch.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/ComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
aria-haspopup="listbox"
aria-expanded="{{open}}"
>

<input id="ui5-combobox-input"
.value="{{_tempValue}}"
inner-input
Expand All @@ -14,6 +13,7 @@
value-state="{{valueState}}"
@input="{{_input}}"
@change="{{_inputChange}}"
@click={{_click}}
@keydown="{{_keydown}}"
@focusin="{{_focusin}}"
@focusout="{{_focusout}}"
Expand Down
80 changes: 53 additions & 27 deletions packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js";
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js";
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { isBackSpace, isDelete, isShow } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js";
import * as Filters from "./ComboBoxFilters.js";

// Styles
import {
INPUT_SUGGESTIONS_TITLE,
} from "./generated/i18n/i18n-defaults.js";

// Templates
import ComboBoxTemplate from "./generated/templates/ComboBoxTemplate.lit.js";
import ComboBoxPopoverTemplate from "./generated/templates/ComboBoxPopoverTemplate.lit.js";

// Styles
import ComboBoxCss from "./generated/themes/ComboBox.css.js";
import ComboBoxPopoverCss from "./generated/themes/ComboBoxPopover.css.js";
import ResponsivePopoverCommonCss from "./generated/themes/ResponsivePopoverCommon.css.js";

import ComboBoxItem from "./ComboBoxItem.js";
import Icon from "./Icon.js";
import Popover from "./Popover.js";
import ResponsivePopover from "./ResponsivePopover.js";
import List from "./List.js";
import BusyIndicator from "./BusyIndicator.js";
import StandardListItem from "./StandardListItem.js";
Expand Down Expand Up @@ -249,6 +259,10 @@ class ComboBox extends UI5Element {
return ComboBoxCss;
}

static get staticAreaStyles() {
return [ComboBoxPopoverCss, ResponsivePopoverCommonCss];
}

static get template() {
return ComboBoxTemplate;
}
Expand All @@ -257,15 +271,12 @@ class ComboBox extends UI5Element {
return ComboBoxPopoverTemplate;
}

static get staticAreaStyles() {
return ComboBoxPopoverCss;
}

constructor(props) {
super(props);

this._filteredItems = [];
this._initialRendering = true;
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
}

onBeforeRendering() {
Expand All @@ -288,7 +299,10 @@ class ComboBox extends UI5Element {
}

onAfterRendering() {
this._width = this.getBoundingClientRect().width;
if (isPhone() && this._respPopover.opened) {
// Set initial focus to the native input
this.inner.focus();
}
}

_focusin(event) {
Expand All @@ -311,13 +325,18 @@ class ComboBox extends UI5Element {

_afterClosePopover() {
this._iconPressed = false;

// close device's keyboard and prevent further typing
if (isPhone()) {
this.blur();
Copy link
Member

@ilhan007 ilhan007 Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little odd, what is the reason for "this.blur()", it is being opening again or?

Copy link
Contributor Author

@dimovpetar dimovpetar Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to close the device keyboard and prevent focus to stay in the ui5-combobox, so that the user can't write in it. The user should only be able to write in the dialog's input

}
}

_togglePopover() {
if (this.popover.opened) {
this.popover.close();
_toggleRespPopover() {
if (this._respPopover.opened) {
this._respPopover.close();
} else {
this.popover.openBy(this);
this._respPopover.open(this);
}
}

Expand All @@ -330,7 +349,7 @@ class ComboBox extends UI5Element {
this.inner.focus();
this._resetFilter();

this._togglePopover();
this._toggleRespPopover();
}

_input(event) {
Expand All @@ -344,7 +363,7 @@ class ComboBox extends UI5Element {
this.filterValue = value;
this.fireEvent("input");

this.popover.openBy(this);
this._respPopover.open(this);
}

_startsWithMatchingItems(str) {
Expand All @@ -357,10 +376,20 @@ class ComboBox extends UI5Element {
if (isShow(event) && !this.readonly && !this.disabled) {
event.preventDefault();
this._resetFilter();
this._togglePopover();
this._toggleRespPopover();
}
}

_click(event) {
if (isPhone() && !this.readonly) {
this._respPopover.open(this);
}
}

_closeRespPopover() {
this._respPopover.close();
}

_filterItems(str) {
return (Filters[this.filter] || Filters.StartsWithPerTerm)(str, this.items);
}
Expand Down Expand Up @@ -402,6 +431,7 @@ class ComboBox extends UI5Element {
const listItem = event.detail.item;

this._tempValue = listItem.mappedItem.text;
this.filterValue = this._tempValue;

this._filteredItems.map(item => {
item.selected = (item === listItem.mappedItem);
Expand All @@ -410,15 +440,7 @@ class ComboBox extends UI5Element {
});

this._inputChange();
this.popover.close();
}

get styles() {
return {
popover: {
"min-width": `${this._width}px`,
},
};
this._respPopover.close();
}

get _filteredItems() {
Expand All @@ -427,12 +449,16 @@ class ComboBox extends UI5Element {
});
}

get _headerTitleText() {
return this.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE);
}

get inner() {
return this.shadowRoot.querySelector("[inner-input]");
return isPhone() ? this._respPopover.querySelector(".ui5-input-inner-phone") : this.shadowRoot.querySelector("[inner-input]");
}

get popover() {
return this.getStaticAreaItemDomRef().querySelector("ui5-popover");
get _respPopover() {
return this.getStaticAreaItemDomRef().querySelector("ui5-responsive-popover");
}

get editable() {
Expand All @@ -443,7 +469,7 @@ class ComboBox extends UI5Element {
await Promise.all([
ComboBoxItem.define(),
Icon.define(),
Popover.define(),
ResponsivePopover.define(),
List.define(),
BusyIndicator.define(),
StandardListItem.define(),
Expand Down
55 changes: 44 additions & 11 deletions packages/main/src/ComboBoxPopover.hbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
<ui5-popover
style={{styles.popover}}
horizontal-align="Left"
?no-arrow={{editable}}
no-padding="true"
placement-type="Bottom"
_disable-initial-focus="true"
<ui5-responsive-popover
no-arrow
_disable-initial-focus
@ui5-afterOpen={{_afterOpenPopover}}
@ui5-afterClose={{_afterClosePopover}}
>

<ui5-busyindicator
<ui5-busyindicator
?active={{loading}}
size="Medium"
class="ui5-combobox-busy"
>
</ui5-busyindicator>

<ui5-list
<div slot="header" class="ui5-responsive-popover-header">
<div class="row">
<span>{{_headerTitleText}}</span>
<ui5-button
icon="decline"
design="Transparent"
@click="{{_closeRespPopover}}"
>
</ui5-button>
</div>
<div class="row">
<div
slot="header"
class="input-root-phone"
value-state="{{valueState}}"
>
<input
class="ui5-input-inner-phone"
.value="{{_tempValue}}"
inner-input
placeholder="{{placeholder}}"
value-state="{{valueState}}"
@input="{{_input}}"
@change="{{_inputChange}}"
@keydown="{{_keydown}}"
aria-autocomplete="both"
/>
</div>
</div>
</div>

<ui5-list
separators="None"
@ui5-itemClick={{_selectItem}}
mode="SingleSelect"
Expand All @@ -31,4 +57,11 @@
</ui5-li>
{{/each}}
</ui5-list>
</ui5-popover>

<div slot="footer" class="ui5-responsive-popover-footer">
<ui5-button
design="Transparent"
@click="{{_closeRespPopover}}"
>OK</ui5-button>
</div>
</ui5-responsive-popover>
1 change: 1 addition & 0 deletions packages/main/src/DatePicker.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
></ui5-icon>
{{/unless}}
</ui5-input>

<slot name="formSupport"></slot>
</div>
Loading