I believe it is clear that a druid in Wild Shape is a beast and therefore1 a valid target for the dominate beast spell:
You attempt to beguile a beast that you can see within range.
I am having trouble determining what happens if Wild Shape ends while the spell is still affecting the druid, namely based on this part of the spell:
It must succeed on a Wisdom saving throw or be charmed by you for the duration.
According to this line, one would assume that after being affected, the spell no longer cares whether the target is still a beast, so the druid would continue to be charmed.
The spell description continues (emphasis mine):
While the beast is charmed, you have a telepathic link with it as long as the two of you are on the same plane of existence. [...]
Now the part about the telepathic link specifies "the beast", so the link should perhaps be broken.
The worst part comes from the next paragraph that simply states (emphasis mine):
You can use your action to take total and precise control of the target. [...]
I assumed that this action uses the telepathic link but that is not specified and is actually in a separate paragraph, so I have no idea how this would work.
Is there a rule I am missing or is this ultimately just up to the DM to decide how this interaction should work?
1 Per this tweet by Mike Mearls
*Druid uses wild shape, are they a valid target for dominate beast or dominate person? What about w/ polymorph?
their type becomes beast, so they can be affected by spells according to that type