You wrote "when form A is opened it should detect which tab page is active and filter data accordingly for form B." - I'm not sure what this means? Form B is not open at this point, right? So what's the requirement?
When the form is opened, I think that the first tab page is open by default. And whenever user changes the tab, tabChanged method is called. You can override that method to see the original and new tab page, and store this in a variable. So, this is how you can always know the current tab page.
When user navigates to another form, you can pass any information from A to B. Either by sending it via args when the MenuItemButton is clicked, or by element.args().caller() in form B - this will return you the FormRun of form A, letting you access all properties of the caller form.
So, at this point you are in form B, and you know what tab page was active in form A, and you can use this info to filter data.