The coronavirus pandemic put investor irrationality on display with intense market gyrations that pushed some stocks sharply lower and others sharply higher. In many cases, those directions ended up reversing -- big time.

Clorox (CLX -0.14%) was one such stock caught up in the mayhem. Investors should probably see the negative mood on Wall Street surrounding the stock today as a long-term opportunity.

The big up

One piece of Clorox's consumer staples business is cleaning products, including disinfecting wipes. During the early days of the coronavirus pandemic consumers started to clean just about everything, leading to huge demand for cleaning supplies. Clorox leaned into this demand, using it to build out its cleaning product portfolio on a global scale. That demand, however, was always destined to be temporary. 

A person cleaning a counter in their new home kitchen.

Image source: Getty Images.

Clorox was aware of this from the very beginning, opting to use contract manufacturers instead of trying to build its own factories as it worked to meet surging demand. It is more costly to hire other companies like this, but it also affords the ability to pivot and end the relationships when things change.

That's exactly what Clorox has done now that demand for cleaning products has pulled back. However, the company's effort to expand its cleaning business during the pandemic has left it with a bigger business than it had prior to the health scare.

That's the type of strategic, long-term thinking that investors should be happy to see a company make. Yes, the normalization process has been tough, leading to overall sales declines -- but at the end of the day Clorox should end up a better company.

And then inflation

One area in which Clorox has had less success has been inflation. That's not actually a knock on management, since inflation has been raging throughout the consumer staples space. There's really not a lot a company can do about it, other than cut costs and raise prices. Both are in the cards at Clorox. There's just a time lag between when the company's margins get crimped and when it can start to recover lost ground. In this case, the normal trends are being exacerbated by the coronavirus cleaning spike, which is also deflating at the same time. 

The big picture looks ugly, but when you dig in a little things aren't really all that bad. For example, Clorox's margins have inflected higher after hitting a nadir in early 2022. And management is being very clear that there is no quick fix, indicating it is likely to take several years to fully restore historical margin levels. That means there's no rush to jump into the stock -- but don't wait so long you miss the opportunity.

Meanwhile, the company's product portfolio outside of cleaning held up fairly well in fiscal 2022, which ended in June. That highlights the overall strength of the company's offering, which includes things like charcoal, kitty litter, lip balm, and salad dressings. And while the fiscal first quarter of 2023 wasn't as positive, with sales dropping slightly across all of Clorox's business units, there's no particular reason to think that the company can't correct course over time. The trends here aren't wildly out of line with broader industry shifts, as higher prices lead consumers to shift toward lower priced products. 

One of the biggest reasons for confidence, meanwhile, comes from the dividend, which has been increased annually for over four decades. There have been a number of really hard periods over that span, including the Great Recession between 2007 to 2009. The recent sell off, meanwhile, has pushed Clorox's dividend yield up toward the high end of its historical yield range, at roughly 3.3%. That suggests that investors are pricing the stock cheaply right now, at least for those intrepid enough to look past the near-term headwinds.

Now is the time to buy

Forget trying to find the perfect time to buy a stock as you'll end up missing the boat. It is better to find a great company going through a rough patch that has proven over time that it can survive adversity. That's a pretty good description of Clorox, with the current headwinds leading to a sharp price decline and, thus, an attractive dividend yield for investors that think in decades and not days.