Fixed 500 on timeline create in accessibility mode

Implements https://www.openproject.org/work_packages/4761

Suggested changelog entry:
* `#4761` Fix: Internal error when creating or editing timeline in accessibility mode