Shakil Choudhury
Thank you so much for providing the app. I took a look and I do see the same behavior as you described. For testing purposes, I did also copy the code into my own app and was able to see the same issue as well. However, what I found was that after modifying the Expand widget to have the "Expanded" property set to false instead of true, it will open and close without any cutoff.
See below:
var legendExpand = new Expand({
expandIconClass: "esri-icon-layer-list",
expandTooltip: "Expand Legend",
collapseTooltip: "Collapse",
expanded: true,
mode:"drawer",
view: view,
content: legend,
group: "top-right"
Is this something you can try and/or work with?
In any case, I have went ahead and logged a bug against this because it should still work regardless to keep the button in place whether this property is set to true or false. If you have any questions in regards to the bug, feel free to contact Esri Support and they can assist with that.