Kadence Blocks has a Table of Contents block. The block doesn’t work on a sidebar, though. However, you can make an element using Kadence Pro to replace a sidebar. When you add a Table of Contents block to the custom sidebar, it will work, and I have used this method in the past.
]]>