Note that this MR is based on !219 which needs to be merged first ino 8.x-1.x, then this MR rebased and then merged.
Closes #3562282.