appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.55k stars 3.73k forks source link

[Feature]: beforeTabSelected event on Tabs widget #18908

Open somangshu opened 1 year ago

somangshu commented 1 year ago

Is there an existing issue for this?

Summary

As a user I should be able to fire an event before a new tab is selected in the tabs widget. There should be an new property present called as beforeTabSelected / beforeTabChanged for me to choose an JS function / Query / API to fire

Why should this be worked on?

Context from a real world scenario

I have multiple tabs and want to prevent the user to switch tabs without saving changes. Preferably with a single function in a JSObject or a property in the tabs widget itself.

dilippitchika commented 1 year ago

@somangshu can you link to original issue? Also a technical doubt, how will we know something before it has happened? Does it make sense to add onTabSelected event instead?

somangshu commented 1 year ago

@dilippitchika @ashit-rath

Ref #18369

dilippitchika commented 1 year ago

Why do you think this is high priority @somangshu? Or was it added by accident?

  1. The onTabSelected event can have a previousTab and currentTab as meta properties to know which tab was previously selected. Executing a query before switching tab, this looks like we need a way to change tab using a framework function like changeTab(tab1).

Let me think about it and get back.

dilippitchika commented 1 year ago

@somangshu haven't heard back from the user yet. I am removing the high priority tag for now and adding the discussion we had on chat here.

dilippitchika commented 1 year ago

Suggested solution Instead of giving an event we can give devs the power to

  1. Disable a tab with JS
  2. Add a tooltip on tab so that they can communicate with users on why tab is disabled