Skip to content

[Feature Request] Add an onInit callback option to VirtualSelect.init() for reliable dynamic interaction. #449

Description

@YuraKril

We are encountering a race condition when initializing the component and immediately attempting to call methods like select.open() on the dynamically created element. The method often executes too early, before the component's internal structure (specifically, the full setup within afterRenderWrapper and initDropboxPopover) is complete.

This requires developers to rely on unreliable workarounds like setTimeout or manual polling (setInterval checking for select.virtualSelect), which leads to fragile and complex code.

Proposed Solution

Please introduce an optional onInit (or onReady) callback within the options object passed to VirtualSelect.init().

This callback function should execute after the component has fully completed its internal initialization process, specifically:
After the new VirtualSelect() constructor completes.
After the entire execution of the this.afterRenderWrapper() method (where all DOM events, styling, and the PopoverComponent are initialized).

Example of the Desired Reliable Usage:

const config = {
  // ... other options ...
  // New onInit option
  onInit: function(instance) {
    // The component is guaranteed ready here!
    instance.open(); 
  }
}

VirtualSelect.init(config);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions