Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6152] iPad: Toggle popover

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T19:29:43.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterSindre Sorhus
AssigneeIngo Muschenetz
Created2011-10-30T08:16:39.000+0000
Updated2020-01-09T19:29:43.000+0000

Description

It would be nice if there was a way to toggle the Ti.UI.iPad.Popover. The usual usecase is that you have a button that opens the popover. If the button is clicked while the popover is visible, nothing happens, but the expected action is that the visible popover is dismissed.

Testcase

The testcase shows that if you click the button while the popover is open, nothing happens. What I would like to do is to just switch out the ".show" method with ".toggle" and then it would work as intended.
Ti.UI.backgroundColor = '#fff';

var win = Ti.UI.createWindow();

var button = Ti.UI.createButton({
	title: 'Open popover',
	width: 150,
	height: 40
})

var popover = Ti.UI.iPad.createPopover({
	height: 300,
	width: 300,
	backgroundColor: '#fff'
});

button.addEventListener('click', function() {
	popover.show({
		view: button
	});
});

win.leftNavButton = button;

win.open({
	modal: true
});
This could be easily solved by having a method on the popover object called ".toggle()", that will show the popover if it's not visible, otherwise hide it. There is a [simple way of doing this](http://stackoverflow.com/questions/2642405/dismissing-ipad-uipopovercontroller-when-barbuttonitem-is-pushed-while-its-open) on StackOverflow.

Comments

  1. Paul Dowsett 2011-11-10

    A nicely-constructed ticket, Sindre - thank you for the obvious thought you put into it.
  2. Sindre Sorhus 2012-07-08

    This feature would be very useful, but still haven't seen any love. If someone could take a look at this ticket, that would be awesome.
  3. Sindre Sorhus 2013-03-01

    bump
  4. Sindre Sorhus 2013-08-28

    bump! This has been open for a really long time with no solution. This is a good ticket, with a testcase and link to a really simple fix. I find it annoying that you would just ignore this for so long.
  5. Sindre Sorhus 2014-05-07

    bump
  6. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. Updating, or creating code may not reproduce the issue reported, or be a valid test case. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source