Closed
Description
Using the example here:
https://github.com/php-school/cli-menu/blob/master/examples/toggle-item-extra.php
but changing the following
->addItem('First Item', $itemCallable, true)
->addItem('Second Item', $itemCallable, true)
->addItem('Third Item', $itemCallable, true)
to
->addItem('First Item', $itemCallable, false)
->addItem('Second Item', $itemCallable, false)
->addItem('Third Item', $itemCallable, false)
creates the item-extra string outside of terminal window:
Toggling the items to trigger $item->hideItemExtra()
does not hide the item-extra strings.
A workaround is passing true
to addItem()
then looping through all items and hiding item-extra:
$itemCallable = function (CliMenu $menu) {
$item = $menu->getSelectedItem();
$item->showsItemExtra()
? $item->hideItemExtra()
: $item->showItemExtra();
$menu->redraw();
};
$menu = (new CliMenuBuilder)
->setTitle('Basic CLI Menu')
->addItem('Option 1', $itemCallable, true)
->addItem('Option 2', $itemCallable, true)
->addItem('Option 3', $itemCallable, true)
->addLineBreak('-')
->build();
foreach ($menu->getItems() as $item) {
$item->hideItemExtra();
}
$menu->open();
This shows an initial list without the item-extra string, allows toggling an item to show item-extra, and allows toggling again to hide the item-extra string.
Metadata
Metadata
Assignees
Labels
No labels