I've had this happen on the Model S. Opening the door normally causes the window to lower by a fraction of an inch so it's not touching the rubber seal around the top. After the door is closed, the window rolls up again by the same amount to the fully sealed position.
When the problem occurred, the second part of that equation was missing: the window didn't raise automatically when the door closed. So every time the door was opened, the window would get slightly lower. I remember being very surprised to see the window down by an inch or more, then realized I had opened and closed the passenger doors a couple of times before leaving the car.
There is a calibration procedure to follow, where you raise the window all the way up, then hold the button down and keep holding it for a few seconds after the window is fully down, then raise the window back up and keep holding the button up for a few seconds after it hits the top. That usually worked to restore the auto-lower-and-raise functionality.
In my case, the front passenger window developed another problem where it would only go halfway up and then reverse and go all the way down again. The service center ended up replacing the window regulator under warranty. Haven't had any problem with the window since.