It's best practices to nest the element to be arrayed, especially if it's dimensions are to be changed after it's arrayed. Create the shelf as a separate family (and shared if you like), and then nest it into the family it's arrayed in. Then associate it's INSTANCE Parameters to the Host Parameters of the same name. Parameters in nested family must be Instance Parameters.
...see attached. It fixes length issue you were having without nesting, yet I cannot promise it will work 100% of time. It could break. As I suggested, it's better to nest.
...forgot to mention: I constrained the actual sketch for the shelf. Go into edit sketch mode for the shelf to see what I did.