But what if they don't want to hire a racist but you just don't say anything overtly racist during company time, while at home you dress up in a klan outfit?
I don't see what that has to do with job performance. This is something I'm in two minds about. On one hand, I fully support freedom of association. If someone doesn't want to hire you based on your views, I think it's their right to reject your application based on that fact alone. On the other hand, employers policing speech is not something I endorse - in your private life you should be able to voice whatever opinions you want, you do not represent the business in your free time, you represent yourself. Over time I've come to the conclusion that the way to adjudicate that fairly is actually rather simple.
If the employer was unaware of some kind of activity you're involved in at the time of hiring, that's tough luck. A contract is binding for both parties, both parties signed on the dotted line and both must necessarily uphold their end of the agreement. The onus is on the employer to interview and validate candidates for a given position, at the point of hiring - that was the time to decide whether a person aligns with the company or not. If the employer failed to screen candidates adequately, too bad - as long as the employee's job performance is satisfactory, I see no reason to fire them, particularly not for exercising their rights.
I don't like the idea of mobs forcing people out of jobs because they disagree with them, even if *I* disagree with them as well. Your example is a little absurd, but the framework still applies. An employment contract outlines precisely what is expected of the employee, and if it includes any violation of the employee's rights, I think it should be de facto null and void. That's in a perfect world, however - everybody knows that these days behaviour on social media is often times mentioned in those contracts. A sad state of affairs, to be sure.
For the record, this applies regardless of political alignment. I'm a conservative person, and I would not knowingly enter into a business arrangement with someone who endorses communism, for instance. That said, I would not terminate a business relationship after the fact - an agreement is an agreement. I might not renew it once it lapses, I might choose not to engage in future agreements with that individual, but I would fulfill the commitment I've made unless the other party broke the contract first.
To be fair though, this is not a firm belief. In an ideal world there'd be no such thing as a "protected class" and everyone would just focus on fulfilling their contracts to the t, but I have to work within the framework we've got. I can be swayed one way or the other, depending on the circumstances.