Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete doesn't work properly #30249

Closed
nicobytes opened this issue Oct 4, 2024 · 1 comment · Fixed by #30269
Closed

Autocomplete doesn't work properly #30249

nicobytes opened this issue Oct 4, 2024 · 1 comment · Fixed by #30269

Comments

@nicobytes
Copy link
Contributor

Parent Issue

No response

Problem Statement

Autocomplete doesn't work properly in template section.

primg.mp4

Steps to Reproduce

  1. Go to the Templates section
  2. Select a template
  3. Click the Edit Classes button
  4. Show Suggest Option

Acceptance Criteria

Working as documented

https://www.dotcms.com/docs/latest/designing-a-template-with-a-theme#ClassSuggestions

dotCMS Version

lastest

Proposed Objective

User Experience

Proposed Priority

Priority 4 - Trivial

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@nicobytes nicobytes self-assigned this Oct 4, 2024
@nicobytes nicobytes linked a pull request Oct 5, 2024 that will close this issue
3 tasks
nicobytes added a commit that referenced this issue Oct 5, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
nicobytes added a commit that referenced this issue Oct 7, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 7, 2024
### Parent Issue
#30249 

### Proposed Changes
* Change singal approach

### The problem

This computed signal caused the error:

```ts
$filteredSuggestions = computed(() => {
    const classes = this.$classes();
    const query = this.$query();

    if (!query) {
        return classes;
    }

    return classes.filter((item) => item.includes(query));
});

filterClasses({ query }: AutoCompleteCompleteEvent): void {
    this.$query.set(query);
}
```

The signals functionality in PrimeNg doesn't works very well. In the
previous signal, `$filteredSuggestions` doesn't trigger a change if the
classes or query are the same as the current state. This is desirable.
However, PrimeNg
[waits](https://github.com/primefaces/primeng/blob/d6c7ffcfc5cb9a8ed355399ddae276c279836ccf/src/app/components/autocomplete/autocomplete.ts#L541)
for a change in the `suggestions` input after the `completeMethod` is
called to turn off the loading. This is why the loading indicator
remains active but never deactivates.

To address this, we manually forced a change in `$filteredSuggestions`
and used `[...filteredClasses]` to create a new array.

```ts
filterClasses({ query }: AutoCompleteCompleteEvent): void {
      const classes = this.$classes();
      const filteredClasses = query ? classes.filter((item) => item.includes(query)) : classes;
      this.$filteredSuggestions.set([...filteredClasses]);
  }
```

### Checklist
- [x] Tests
- [x] Translations
- [x] Security Implications Contemplated (add notes if applicable)

### Screenshots



https://github.com/user-attachments/assets/5a199569-9192-4acb-89bd-3fb6530aefce
@nicobytes
Copy link
Contributor Author

QA Notes:

  1. Configure your json according to the docs
  2. Go to temaplates sections
  3. Add and remove classes
2024-10-07.10-03-18.mp4

@oidacra oidacra assigned oidacra and unassigned nicobytes Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Internal QA
Development

Successfully merging a pull request may close this issue.

2 participants