pat-contentbrowser: search mode duplicates its content at every load

Open Beginner friendly
#1,683 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
frontend

Research direction

Start with the ContentBrowserFieldWidget implementation and the content browser search mode, then trace what happens when the modal is closed and opened again. Reproduce the steps in the issue using {"mode": "search"} and compare with the default browse mode. Done means reopening the modal shows each existing content item only once.

Written by the indexing model from the issue text.

Description

01 type: bug

Describe the bug

By setting the configuration option "mode": "search" on a field that uses the ContentBrowserFieldWidget widget, on the add/edit form, every time that the widget is loaded, the list of elements gets duplicated, as if the widget fetches the default results and appends them rather than replacing the existing ones that are kept somewhere...

The default browse mode does not show this bug.

To Reproduce

Steps to reproduce the behavior:

  1. Go to `/Plone/portal_registry/
  2. Edit the plone.patternoptions option adding contentbrowser as a new key and {"mode": "search"} as its value and save it
  3. Go to the Plone site root, try to create a Page document, select the Categorization tab and click on Select on the Related items field.
  4. A list of existing content will be shown
  5. close that modal and open it again
  6. The list of existing content gets duplicated

Note that the default modal to edit the registry configuration does not work as it closes the modal as soon as you click on Add you need to open it on its own browser tab, i.e. /Plone/portal_registry/edit/plone.patternoptions

Expected behavior

No duplicated content is shown

Software (please complete the following information):

Tested it locally but also reproducible in https://classic.demo.plone.org

Dominant language
JavaScript
Stars
57
Forks
103
Avg merge
2d 15h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/mockup

All issues in plone/mockup

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.