Repository navigation
Description
Bug Report
Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.
Ionic:
ionic (Ionic CLI) : 4.1.2
System:
NodeJS : v8.11.1
npm : 6.3.0
OS : Windows 7
I am creating stenciljs web component(s): @stencil/core: 0.12.4
Describe the Bug
I have one ion-select component that I want to hold different ion-select-options based on a previous ion-segment group selection. the selection of each ion-segment selection builds an array of items to pass to my stencil component. (the 'item' list gets built appropriately). If I select an ion-segment that creates a list of length > 0 the action-sheet is populated as expected, however If I then select an ion-segment that populates a list of length == 0 (meaning there are no items in the ion-select-options) when I select the dropdown I expected to see only a cancel option but the previous list is still there.
Steps to Reproduce
step1: render the ion-select (interface="action-sheet") component with 3 ion-select-option components
step2: re-render the ion-select component with 0 ion-select-option components.
Here is my component
import { Component, Element, Event, EventEmitter, Listen, Prop, State } from '@stencil/core';
@Component({
tag: 'tracker-planner-select-item',
styleUrl: 'tracker-planner-select-item.scss'
})
export class TrackerPlannerSelectItem {
@Element() el: HTMLTrackerPlannerSelectItemElement;
@Prop() id: string;
@Prop() items: { key: string,
value: string
}[];
@Prop() label: string;
@State() _items: { key: string,
value: string
}[];
@Event() trackerSelectChange: EventEmitter;
@Listen('ionChange')
onIonChange(event: CustomEvent) {
event.preventDefault();
event.stopPropagation();
this.trackerSelectChange.emit({ ...event.detail, id: this.id });
}
componentWillUpdate() {
// Trying to clean up action-sheet
this._items = (this.items && this.items.length > 0) ? this.items : undefined;
(this.el.querySelector('ion-select#' + this.id) as HTMLIonSelectElement).interfaceOptions = {
header: this.label,
subHeader: 'Select the lesson for this plan'
};
}
render() {
return (
<ion-item>
<ion-label>{this.label}</ion-label>
<ion-select name={this.id ? this.id : null} id={this.id ? this.id : null} interface="action-sheet" placeholder="Select One">
{ this._items
? this._items.map(element => <ion-select-option value={element.key}>{element.value}</ion-select-option>)
: null
}
</ion-select>
</ion-item>
);
}
}
Expected Behavior
I expected to see the correct array being populated even if previously there were say 10 and then the component was updated with 0
Additional Context
After looking through the generated HTML code there are no generated after rendering the component back to an empty array, however, the previous action-sheet-buttons are still present so I am guessing that the action-sheet-buttons is not being generated properly if the new array of ion-select-options is 0.
Activity
paulstelzer commentedon Dec 7, 2018
Thanks for your issue! Could you please check if this is still an issue in
beta.17? That would be very nice :)frenmanoj commentedon Dec 10, 2018
Hello @paulstelzer ,
Yes, this issue still exists in
beta.17. The action sheet is not reflecting the dynamically updated list of theoptionsdata. One thing to note here is, if you inspect the HTML elements, the DOM contains proper number ofion-select-optionelements. So, the issue here isAction Sheetis not getting updated even ifion-select-optiondoes.fix(all): component reusage (#18963)
fix(all): component reusage (#18963)
fix(all): component reusage (#18963)
liamdebeasi commentedon Sep 4, 2019
A fix for this is available in Ionic 4.9.0. For any new bugs, please create a new issue.
Thanks!
ionitron-bot commentedon Sep 26, 2019
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.