When right clicking on a block you get out of the minecart(and i guess any rideable object) for a short moment and come back. happens on survival too. when i tested it wasnt working on walls just on the floor.
this is where i was clicking on.
MC-14524 Right Clicking On Minecart / Pig / Boat While Riding In It Tries To Remove You