Categorized Forms - pre-select a category in UI-Schema?

I have a question about categorized forms:
Is it possible to define in the schema which category is active, or does the form always start with the first category in the list?

Hi @rsoika,

This functionality is not offered out of the box but can certainly be added using a custom renderer for Categorization.

Hi @sdirix ,
thanks. I have solved it now in my client code by creating a onClick event in the setState method. This method is always called after the form content changed.

            // try to pre-select the last category
            const listCategories = this.bodyDiv.querySelectorAll('ul.category-subcategories li');
            for (let i = 0; i < listCategories.length; i++) {
                // Check if the LI element's text content matches our lastCategory
                if (listCategories[i].textContent === this.lastCategory) {
                    // Simulate the click event on the LI element
                    const event = new MouseEvent('click', {
                        view: window,
                        bubbles: true,
                        cancelable: true
                    });
                    listCategories[i].dispatchEvent(event);
                    break;
                }
            }

Peek 2023-03-06 17-48

I guess that’s a way to do it xD

Personally I would prefer the custom renderer to avoid tricks like that but if it works for you that’s fine.