From 1c9c18b5eaa5807b802829586ec5fffb53f0d345 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 13 Feb 2019 08:34:55 -0500 Subject: [PATCH] fix(select): Account for when options are not loaded immediately (#17405) * Added logging to begin debugging issue * identify potential fix, add test * fix(select): render when options are loaded after a delay * fix linter issues * fix e2e test * fix edge case with if statement --- core/src/components/select/select.tsx | 13 +++++++ core/src/components/select/test/async/e2e.ts | 10 +++++ .../components/select/test/async/index.html | 37 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 core/src/components/select/test/async/e2e.ts create mode 100644 core/src/components/select/test/async/index.html diff --git a/core/src/components/select/select.tsx b/core/src/components/select/select.tsx index 7b9f4b704e..22c1432833 100644 --- a/core/src/components/select/select.tsx +++ b/core/src/components/select/select.tsx @@ -133,8 +133,21 @@ export class Select implements ComponentInterface { @Listen('ionSelectOptionDidUnload') async selectOptionChanged() { await this.loadOptions(); + if (this.didInit) { this.updateOptions(); + + /** + * In the event that options + * are not loaded at component load + * this ensures that any value that is + * set is properly rendered once + * options have been loaded + */ + if (this.value !== undefined) { + this.el.forceUpdate(); + } + } } diff --git a/core/src/components/select/test/async/e2e.ts b/core/src/components/select/test/async/e2e.ts new file mode 100644 index 0000000000..c6bcd7f727 --- /dev/null +++ b/core/src/components/select/test/async/e2e.ts @@ -0,0 +1,10 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('select: async', async () => { + const page = await newE2EPage({ + url: '/src/components/select/test/async?ionic:_testing=true' + }); + + const compare = await page.compareScreenshot(); + expect(compare).toMatchScreenshot(); +}); diff --git a/core/src/components/select/test/async/index.html b/core/src/components/select/test/async/index.html new file mode 100644 index 0000000000..1c28d31088 --- /dev/null +++ b/core/src/components/select/test/async/index.html @@ -0,0 +1,37 @@ + + + + + + Select - Async + + + + + + + + + + + + +