Hehe, naughty indeed.
This one's easily repeated with your explanation so no screenshot necessary.
Notice that the space you trapped in this case is where the entrance appears if you unlock it, so that particular spot is not a normal floor but a locked entrance. You can install a trap there, but either opening or sealing it permanently changes the "floor" at that position, destroying anything that's attached to it.
The solution is, um, don't install traps on the entrance space--do it one space back (or better from a tactical point of view: at a diagonal since it'll be easier to lure them across it).
Edit: I added a log message so that the player knows why the trap isn't there anymore.