Zend certified PHP/Magento developer

Magento2: How to add a filter for “is_in_stock” on category page layered navigation?

I tried the Magento2: How do I add a filter for “is_in_stock” on category page layered navigation? and it only works correctly for one page. If I have 24 products on my page, I can see a total of 24 products (in stock and out of stock) through these filters. If I filter by them, I see, for example, 23 products on the page and an opportunity to go to the next page. What am I doing wrong?