mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
chore(): sync
This commit is contained in:
@ -267,6 +267,7 @@ export class Picker implements ComponentInterface {
|
||||
|
||||
inputEl.focus();
|
||||
} else {
|
||||
// TODO FW-5900 Use keydown instead
|
||||
el.addEventListener('keypress', this.onKeyPress);
|
||||
this.destroyKeypressListener = () => {
|
||||
el.removeEventListener('keypress', this.onKeyPress);
|
||||
@ -559,6 +560,21 @@ export class Picker implements ComponentInterface {
|
||||
tabindex={-1}
|
||||
inputmode="numeric"
|
||||
type="number"
|
||||
onKeyDown={(ev: KeyboardEvent) => {
|
||||
/**
|
||||
* The "Enter" key represents
|
||||
* the user submitting their time
|
||||
* selection, so we should blur the
|
||||
* input (and therefore close the keyboard)
|
||||
*
|
||||
* Updating the picker's state to no longer
|
||||
* be in input mode is handled in the onBlur
|
||||
* callback below.
|
||||
*/
|
||||
if (ev.key === 'Enter') {
|
||||
this.inputEl?.blur();
|
||||
}
|
||||
}}
|
||||
ref={(el) => (this.inputEl = el)}
|
||||
onInput={() => this.onInputChange()}
|
||||
onBlur={() => this.exitInputMode()}
|
||||
|
||||
@ -163,5 +163,44 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
|
||||
await expect(ionChange).toHaveReceivedEventDetail({ value: 12 });
|
||||
await expect(column).toHaveJSProperty('value', 12);
|
||||
});
|
||||
test('pressing Enter should dismiss the keyboard', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/ionic-team/ionic-framework/issues/28325',
|
||||
});
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-picker-internal>
|
||||
<ion-picker-column-internal></ion-picker-column-internal>
|
||||
</ion-picker-internal>
|
||||
|
||||
<script>
|
||||
const column = document.querySelector('ion-picker-column-internal');
|
||||
column.items = [
|
||||
{ text: '00', value: 12 },
|
||||
{ text: '01', value: 1 },
|
||||
{ text: '02', value: 2 },
|
||||
{ text: '03', value: 3 },
|
||||
{ text: '04', value: 4 },
|
||||
{ text: '05', value: 5 }
|
||||
];
|
||||
column.value = 5;
|
||||
column.numericInput = true;
|
||||
</script>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const column = page.locator('ion-picker-column-internal');
|
||||
await column.click();
|
||||
|
||||
const input = page.locator('ion-picker-internal input');
|
||||
await expect(input).toBeFocused();
|
||||
|
||||
// pressing Enter should blur the input and therefore close the keyboard
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await expect(input).not.toBeFocused();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user