Ashley Lunkenheimer’s campaign for the Democratic nomination in Pennsylvania’s Fifth Congressional District in May was trailed by whispers from some in her own party: It was fine that she was a lesbian, they said, but were voters ready for that?

Gina Ortiz Jones, a Democratic candidate in the 23rd Congressional District in Texas, faced a similar question, but for her it happened out in the open. An opponent in the primary asked her onstage during a candidate forum to make it clear to voters that she was a lesbian so it would not be “revealed later” in a Republican attack.

Catholic voters in the heavily Hispanic district “may still vote for you, but let’s get it out there,” said the opponent, Angie Villescaz.

“She made it seem like I was hiding who I was from voters, as if maybe I was supposed to mention that in every single sentence,” said Ms. Jones, an Air Force veteran who served under “don’t ask, don’t tell,” a law, now repealed, that banned openly gay men, lesbians and bisexuals from military service. “Her implication obviously was if voters knew, then they wouldn’t be voting for me.”