question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

replyMenuToContext not working on submenutemplate

See original GitHub issue

I want to use replyMenuToContext to return to a menu generated when clicking on an option of a choice to chooseIntoSubmenu.

Currently this is not working and it is only possible to return to the full list of options.

const subMenu = new MenuTemplate<TelegrafContext>('Configure')
subMenu.chooseIntoSubmenu('items', ['item1', 'item2'], subMenuTemplate, {columns: 1});

menu.submenu('Configure', 'configure', submenu);

const question = new TelegrafStatelessQuestion('myvalue', async (ctx) => {
  await replyMenuToContext(subMenuTemplate, ctx, '/configure/items:item1);
});

This one is returning:

TypeError: Cannot read property '1' of undefined

However if I put await replyMenuToContext(subMenu, ctx, '/configure/items:item1); it works but returns to the list of options.

Is there any way you can achieve that or the only way I have is to manually create all the menus? I can do that by running a foreach on all the items in the array and generating a real menu for each one, but I’d rather prefer the chooseIntoSubmenu.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EdJoPaTocommented, Aug 28, 2020

Awesome, now I understand what you are trying to do. The menuPath you are using afterwards with replyMenuToContext does not end with a ‘/’. A basic assumption this library does is “a menu ends with /, a button does not”. When you include that final slash, the correct menu is opened.

Send Menu Functions like replyMenuToContext should complain when the path isnt ending with ‘/’ so other people will not fall for the same mistake.

Your exception then results from the ctx.match which doesnt have the entry for the submenu. ~Thats something this library should do, but sadly I dont have the time for that currently.~ Edit: which is not possible from within the library as the menu given has no clue about their parent menues. But you can use menuMiddleware.replyToContext(context, path) which is filling ctx.match correctly.

As you are familiar with RegExp and the path, you can also do it outside of the library in your code.

0reactions
EdJoPaTocommented, Oct 8, 2020

I’ll just close this due to inactivity. If you have any questions feel free to ask ahead!

Read more comments on GitHub >

github_iconTop Results From Across the Web

replyMenuToContext not working on submenutemplate #119
I want to use replyMenuToContext to return to a menu generated when clicking on an option of a choice to chooseIntoSubmenu.
Read more >
MenuItem.SubMenuTemplate Property | ASP.NET Web Forms ...
Use the SubMenuTemplate property to define the common content for the client regions of all submenus of the current menu item. A submenu's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found