Dynamically set actions position.

(cherry picked from commit 37ab5b89cd844b576ed62655a4e044a2f42dfafa)