Sherlock is a bit too honest about his feelings for in front of John's daughter, thinking that she isn't listening/is asleep/doesn't understand. She goes to John and is like "Daddy do you know Uncle Sherlock is very sad because the brave knight he's in love with doesn't want him? Can we do something to help him?" John puts two and two together.
Baby Watson reveals Sherlock's feelings for John