Skip to content

Searchtools issue / desiredOption.length is undefined #46491

@dawe78

Description

@dawe78

I just realized an issue with searchtools. In my custom component, search direction is set to a default value, which results in selected ordering option. Select field example:

<select...>

Title ASC Title DESC Title ASC Title DESC

When I click on id column, ordering select field gets an additional option entry instead of selecting existing option (issue 1) and previous selected option is still selected (issue 2):

<select...>

Title ASC Title DESC id ASC id DESC id ASC `

In my select Model->getListQuery() method "title desc" is set for ordering, no matter which column I selected for ordering.

If I unset default value, behaviour is the same but we got only one selected option, so ordering is done as expected:

<select...>

Title ASC Title DESC id ASC id DESC id ASC `

Summary:
Issue 1: Option is added even if exists:
searchtools.js, line 460: if (desiredOption && desiredOption.length) {
desiredOption has no length, so here we always get false and new option will be added.

Issue 2: "old" option is still selected and should be de-selected before form submit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions