Hi, sorry for the late reply, and thank you for the report.
I'm surprised this is an issue. But here it is.
The selection-tool should be filtered to resources only. In fact, I've just double checked the workings of the selection-tool-setup to see if by accident tile-ghosts were added as a selectable entity, but they're not. So I'm not entirely sure why the selectiontool includes them.
I've briefly tried to tweak the settings of the tool to try and exclude the tile ghosts, to no avail. I actually think this might be a bug in the game itself.
I'll try to find some time soon to fidget some more; and if I can't get the selectiontool filter to work as I need it, I'll try to workaround it in a similar manner as your code suggestion does it.