It helps to acknowledge their issue first, maybe commiserate, and only share something directly related. Then you need to immediately hand the conversation back to them, and listen some more.
Don't say, "Oh, that reminds me of something..." and then talk about seeing a dog on your most recent three-week summer vacation to France.