What Am I doing ?
Which code does that ?
The JS button code lines responsible doing this are -
var recId = window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
window.location.href = '/apex/RecordTypeX_VF?retURL=/'+recId ;
What is happening ?
The page get redirected to desired VF page but the URL doesn't gets update in the browser, i.e. the same old URL gets shown.
So, what is the problem ?
RecordTypeX_VF fetched the RetUrl from page url and shows different Screens based on the navigation (from tab / related list). Now, that the URL isn't getting updated on navigation to RecordTypeX_VF page, the page does not get the retURl and shows the generic view(how it should look when it is coming from tab).