webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

Issue With Reference type field subcomponents order when saving or publishing.

Open MarkiyanPyts opened this issue 3 years ago • 0 comments

Version

5.32.0

Operating System

Mac OS Monterey

Browser

Safari

What are the steps to reproduce this bug?

  1. Create 2 content models say component_model_1 and component_model_2 they both can have only 1 title field of type string it does not matter.
  2. Create a Page content model, for it create components field of type Reference(should be array of references), list component_model_1 and component_model_2 as possible subcomponents
  3. For component_model_1 create 2 content items, call them "component_model_1_content_1", "component_model_1_content_2"
  4. For component_model_2 same but call items "component_model_2_content_1", "component_model_2_content_2"
  5. Now let's assemble the page, to do this we need to create "Homepage" content entry under Page content model, under components reference field add content entries in the following order:
  • component_model_1_content_1
  • component_model_2_content_1
  • component_model_1_content_2
  • component_model_2_content_2

Hit save or save and publish button, check the order

What is the expected behavior?

  • component_model_1_content_1
  • component_model_2_content_1
  • component_model_1_content_2
  • component_model_2_content_2

Order should be preserved after save and page reload

What do you see instead?

  • component_model_1_content_1
  • component_model_1_content_2
  • component_model_2_content_1
  • component_model_2_content_2

Order will not be preserved, webiny will group content items by model type.

Will not work even if you try to change the order from the admin, it will work only until you try to save the change.

Additional information

This will not be an issue if every component on the page uses different content and unique content models(1 content entry per model). But If you try to use 2 different content entries of single model order will be broken.

This prevents creating pages with for example 2 banner components with different images etc.

Possible solution

Ensure Webiny follows the order or components under the reference field specified by the content manager. Not trying to group content entry order by component type.

MarkiyanPyts avatar Sep 12 '22 17:09 MarkiyanPyts