Issue found in ColumnControl with SaveState and search logic icons

Issue found in ColumnControl with SaveState and search logic icons

Elizabeth M SmithElizabeth M Smith Posts: 3Questions: 0Answers: 0

SearchInput._stateLoad() never validates a restored search-logic value against the currently-rendered <option>s before repainting the type icon, so a stale/mismatched saved value renders literal "undefined". - probably should just pop the first option and clear the value if the logic type no longer exists

Kind of hard to reproduce all the time, but I can generally reproduce it it tables using column reorder that are then refreshed - you get "undefined" instead of the correct icon in the search input

Replies

  • Elizabeth M SmithElizabeth M Smith Posts: 3Questions: 0Answers: 0
    if (loadedState) {
        this._loadingState = true;
    
        // Check if the restored logic value exists within the currently rendered options
        let optionExists = Array.from(dom.select.options).some(opt => opt.value === loadedState.logic);
    
        if (optionExists) {
            dom.select.value = loadedState.logic;
            dom.input.value = loadedState.value;
            dom.select.dispatchEvent(new Event('input'));
        } else {
            // Fallback: Default to the first available option's logic to prevent painting "undefined"
            dom.select.selectedIndex = 0;
            dom.input.value = loadedState.value;
            dom.select.dispatchEvent(new Event('input'));
        }
    
        this._loadingState = false;
    }
    

    something like that would probably fix it? Sorry I don't have a dev environment set up for datatables or I'd just do a PR

Sign In or Register to comment.