Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markup.button.callback() doesn't work with hide = true #1902

Open
zigzag-way opened this issue Nov 7, 2023 · 4 comments
Open

Markup.button.callback() doesn't work with hide = true #1902

zigzag-way opened this issue Nov 7, 2023 · 4 comments

Comments

@zigzag-way
Copy link

Context

  • Telegraf.js Version: 4.15.0
  • Node.js Version: 18.4.2
  • Operating System: Windows 11

Minimal Example Code Reproducing the Issue

Markup.inlineKeyboard([[Markup.button.callback(NAME, DATA, true)]]).reply_markup

Expected Behavior

Keyboard array

Current Behavior

Empty array

If we remove the third (hide) parameter
Markup.inlineKeyboard([[Markup.button.callback(NAME, DATA)]]).reply_markup
then everything works fine

@hypernova7
Copy link
Collaborator

It's a normal behavior
Since hide is not a feature of the bot API, but of Telegraf

See markup.ts:130

@zigzag-way
Copy link
Author

It's a normal behavior Since hide is not a feature of the bot API, but of Telegraf

See markup.ts:130

Not sure that I understand you.
Here the doc says that there are three parameters.
callback(text, data, hide?): Hideable<InlineKeyboardButton.CallbackButton>

@hypernova7
Copy link
Collaborator

Of course I understood, only that the hide parameter does not add parameters to the button object of the resulting array, but rather it literally removes the button object from the resulting array

@MKRhere
Copy link
Member

MKRhere commented Nov 8, 2023

Should we remove the feature in v5? I would settle for allowing undefined in the Markup list instead, so you could do something like:

// you have a list of optional { name?: string, id?: string }
const markup = list.map(x => x && x.id && Markup.button.callback(x.name, x.id));

Instead of today:

const markup = list.map(x => Markup.button.callback(x.name || "", x.id || "", Boolean(x.id)));

Is there even a case where hide makes sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants