replyMenuToContext not working on submenutemplate
See original GitHub issueI 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:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 fillingctx.match
correctly.As you are familiar with RegExp and the path, you can also do it outside of the library in your code.
I’ll just close this due to inactivity. If you have any questions feel free to ask ahead!