Open lovo-h opened 2 years ago
I've tried to do the same in https://github.com/woocommerce/woocommerce-gateway-stripe/pull/2243 without success. The problem is that we can indeed show an alert before ~clicking~ switching the tab (we could use the internal WooCommerce's history library for that) but we can't prevent switching tabs after clicking the tab. The TabPanel
doesn't expose a way to stop the click event.
@asumaran, that's correct. An alternative solution would be to create a custom tab panel component that can prevent switching tabs after clicking the tab. This could be a component that would be specifically used for the Stripe extension. I am not a big fan of this approach.
Ideally, we could update the tab panel component so that it behaves as mentioned above (that is, it doesn't automatically switch tabs after clicking the tab but instead, can be hooked into so that the tab switching mechanism can be controlled).
Thoughts?
cc @ricardo
Alternatively, we could use this approach and keep two active tab states. That may also require a custom tab panel component.
@ricardo how that approach would allow us to display a message and prevent switching to the other tab?
how that approach would allow us to display a message and prevent switching to the other tab?
We wouldn't need to display a message or prevent switching tabs because we would allow saving both tabs at the same time, with a "Save keys" button. This was probably the original idea behind the design.
Hey! I would like to solve this issue.
Hey @MuskanMathur28,
Feel free to fork the repository and open a pull request here.
Thank you for your interest in contributing 🙏.
Description
When switching between Live and Test tabs in the Edit live account keys & webhooks modal (see image below), if data has been entered it will be lost upon switching tabs.
Possible Solution
Prompt a message if unsaved changes exist, before switching tabs.
Acceptance Criteria