Ask questionsHistory: Unsetting background media breaks the history

Bug Description

When background media is removed, history stops working. <!-- Please describe clearly and concisely what the bug is. -->

Expected Behaviour

History should work as expected with any relevant action. <!-- Please describe clearly and concisely what the expected behaviour should be. -->

Steps to Reproduce

  1. Add background Media
  2. Remove background Media
  3. Try to use "Undo"
  4. See nothing happening. <!-- Please provide detailed steps on how to reproduce the bug. -->


<!-- If applicable, please add screenshots to help explain your problem. Bonus points for videos! -->

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

Implementation Brief

We will change how background elements work in the reducer level.

New invariants:

  • A page will always have a background element, which is the lowest-most element in the element list.
  • A new page must come with a default background element.
  • Whenever the background element is changed, if the old background element is the default background, it will be "moved" temporarily (with all attributes intact) to another property inside the page as a "default background element".
  • Whenever the background element is unset, if it's the default background element, nothing happens. If it's not, there will be a "default background element" to restore as the new background element.
  • The backgroundElementId property will be removed from the page, as it is now always similar to elements[0].id and can never be null anymore.


  • usePageBackground can be removed.
  • createPage will be split into createPage and duplicatePage as they're now rather different.
  • arrangeElement can be simplified, as there will always be a background element to disregard (and not just sometimes as now).
  • selectElement, toggleElement and setSelectedElement must be adapted to manually retrieve id of bottom-most element rather than just reading it from page.
  • All other checks for backgroundElementId (mostly in canvas and output components) can be replaced by either checking isBackground property on element or position in elements list.
  • A migration must be added.
  • Tests and types must be updated.

QA Instructions


Answer questions pbakaus

I'd rate this P0 because there's an element of data loss here.


Related questions

No questions were found.
Github User Rank List