[#33150] Use data-direction attribute to update direction (Fix #2797)