eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

Picker-dropdown remains on a new page #1865

Open elshadsm opened 5 years ago

elshadsm commented 5 years ago

Problem description

When a picker is expanded and no interaction is performed until a new page is opened, the picker-dropdown still appears on the new page.

Expected behavior

The picker-dropdown must not be displayed in other pages.

Environment

Code snippet

const { NavigationView, Page, Picker, contentView } = require('tabris');

const AIRPORTS = [
  {
    id: 'SFO',
    name: 'San Francisco'
  },
  {
    id: 'TXL',
    name: 'Berlin Tegel'
  },
  {
    id: 'FRA',
    name: 'Frankfurt'
  }
];

let navigationView = new NavigationView({
  left: 0, top: 0, right: 0, bottom: 0
}).appendTo(contentView);

let page = new Page({
  title: 'Page'
}).appendTo(navigationView);

page.append(
  new Picker({
    left: 20, top: 20, right: 20,
    itemCount: AIRPORTS.length,
    itemText: (index) => AIRPORTS[index].name,
    selectionIndex: 1
  })
);

setTimeout(() => {
  new Page({
    title: 'New Screen',
    background: 'green'
  }).appendTo(navigationView);
}, 5000);

iOS

File

Android

Screenshot_20190426-172943

mpost commented 5 years ago

The picker drop down is actually similar to dialog (it is a Window) on android. just overlaying the current page with a new page does not change the appearance of the picker window. Some extra measures would need to be taken.

karolszafranski commented 5 years ago

It’s the same case on iOS. I would rather think about new API which would allow you checking the state and toggling the visibility of the dropdown than hiding it automatically.

patrykmol commented 5 years ago

I have made a workaround in native code where setting visible to false will dispose of picker.

mpost commented 5 years ago

@patrykmol That would be correct. I would also expect that setting enabled to false would close the picker.

patrykmol commented 5 years ago

@mpost I made enabled to dismiss Picker when it's set to false.

@elshadsm @mpost Is this issue still valid after these fixes? Please close if it's no longer valid.

mpost commented 5 years ago

@patrykmol I would think it is still valid. When covering the Picker with another view, the "selection ui element" is still visible. Since the "selection ui" is not connected to the actual Picker, we should add API to close the picker. As mentioned before, this should automatically happen when the Picker is disabled, made invisible, removed from the parent or disposed.