Revise code before list widget definition (fixes #27929)