I believe an employee should keep their exit a secret *until* they give their X-Weeks-Notice.
I had one position where I was honest about wanting to expand my skills in a different role, that particular employer didn’t have that role for me, so I expressed that I’d be looking for that role elsewhere. It was all very nice and cordial — I even got a raise, a hefty bonus and a shining performance review… Just three months before they let me go.
I hadn’t found another job that suited my needs in those three months, so I stayed there and I worked hard and earned my keep, but for the fact that I told my employer my intentions, they weren’t having it. They rather have someone they knew would be around a lot longer, and so I got the shaft. They even tried to deny my unemployment insurance after I was laid off stating that I was looking for another job anyway so that in their eyes, I effectively quit. Of course, I won the unemployment benefits, but it was a shady and underhanded move by my former employer.
I will never let any employer or fellow employee know that I plan to leave a company until I know the exact date my last day will be, and I notify HR of my X-Weeks-Notice. Period.