Skip to content

[Ionic V4-beta.11] ion-select interface="action-sheet" action sheet list of buttons do not clear when no ion-select-options are added to ion-select #15879

Closed

Description

@outpost91

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

  1. paulstelzer commented on Dec 7, 2018

    @paulstelzer
    Contributor

    Thanks for your issue! Could you please check if this is still an issue in beta.17? That would be very nice :)

  2. added
    needs: reply
    and removed on Dec 7, 2018
  3. frenmanoj commented on Dec 10, 2018

    @frenmanoj

    Hello @paulstelzer ,

    Yes, this issue still exists in beta.17. The action sheet is not reflecting the dynamically updated list of the options data. One thing to note here is, if you inspect the HTML elements, the DOM contains proper number of ion-select-option elements. So, the issue here is Action Sheet is not getting updated even if ion-select-option does.

  4. added and removed
    needs: reply
    on Dec 10, 2018
  5. added this to the Stencil One milestone on Jun 10, 2019
  6. added a commit that references this issue on Aug 27, 2019
    48a2763
  7. added a commit that references this issue on Aug 27, 2019
    7eb1089
  8. added a commit that references this issue on Aug 27, 2019
    69ee964
  9. liamdebeasi commented on Sep 4, 2019

    @liamdebeasi
    Contributor

    A fix for this is available in Ionic 4.9.0. For any new bugs, please create a new issue.

    Thanks!

  10. ionitron-bot commented on Sep 26, 2019

    @ionitron-bot

    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.

  11. locked and limited conversation to collaborators on Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: core

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions