Repository: oppia/oppia
File: core/templates/pages/library-page/search-bar/search-bar.component.ts (TypeScript)

Code before:
        'I18N_LIBRARY_ALL_' + itemsName.toUpperCase() + '_SELECTED';
    }
  }

  toggleSelection(itemsType: string, optionName: string): void {
    let selections = this.selectionDetails[itemsType].selections;
    if (!selections.hasOwnProperty(optionName)) {
      selections[optionName] = true;
    } else {
      selections[optionName] = !selections[optionName];
    }

    this.updateSelectionDetails(itemsType);
    this.refreshSearchBarLabels();
  }
  deselectAll(itemsType: string): void {
    this.selectionDetails[itemsType].selections = {};
    this.updateSelectionDetails(itemsType);
    this.refreshSearchBarLabels();
  }

  /**
   * Triggers a search query when the dropdown menu is closed.
   * @param {boolean} isOpen - The new open state of the dropdown.
   */
  onDropdownClose(isOpen: boolean): void {
    if (!isOpen) {
      this.onSearchQueryChangeExec();
    }
  }

  onSearchQueryChangeExec(): void {
    let searchUrlQueryString = this.searchService.getSearchUrlQueryString(
      this.searchQuery,
      this.selectionDetails.categories.selections,
      this.selectionDetails.languageCodes.selections
    );
    this.searchService.executeSearchQuery(
      this.searchQuery,
      this.selectionDetails.categories.selections,
      this.selectionDetails.languageCodes.selections,
      () => {
        let url = new URL(this.windowRef.nativeWindow.location.toString());
        let siteLangCode: string | null = url.searchParams.get('lang');
        url.search = '?q=' + searchUrlQueryString;
        if (this.windowRef.nativeWindow.location.pathname === '/search/find') {
          if (siteLangCode) {
            url.searchParams.append('lang', siteLangCode);
          }
          this.windowRef.nativeWindow.history.pushState({}, '', url.toString());
        } else {

Review comment (suggestion):
Can you please rename this method? Currently, `onDropdownClose` is very generic menthod name and does not helps to understand the context and functionality.


Code after:
        'I18N_LIBRARY_ALL_' + itemsName.toUpperCase() + '_SELECTED';
    }
  }

  toggleSelection(itemsType: string, optionName: string): void {
    let selections = this.selectionDetails[itemsType].selections;
    if (!selections.hasOwnProperty(optionName)) {
      selections[optionName] = true;
    } else {
      selections[optionName] = !selections[optionName];
    }

    this.updateSelectionDetails(itemsType);
    this.refreshSearchBarLabels();
  }
  deselectAll(itemsType: string): void {
    this.selectionDetails[itemsType].selections = {};
    this.updateSelectionDetails(itemsType);
    this.refreshSearchBarLabels();
  }

  /**
   * Triggers a search query when the dropdown menu is closed.
   * @param {boolean} isOpen - The new open state of the dropdown.
   */
  triggerSearchOnDropdownClose(isOpen: boolean): void {
    if (!isOpen) {
      this.onSearchQueryChangeExec();
    }
  }

  onSearchQueryChangeExec(): void {
    let searchUrlQueryString = this.searchService.getSearchUrlQueryString(
      this.searchQuery,
      this.selectionDetails.categories.selections,
      this.selectionDetails.languageCodes.selections
    );
    this.searchService.executeSearchQuery(
      this.searchQuery,
      this.selectionDetails.categories.selections,
      this.selectionDetails.languageCodes.selections,
      () => {
        let url = new URL(this.windowRef.nativeWindow.location.toString());
        let siteLangCode: string | null = url.searchParams.get('lang');
        url.search = '?q=' + searchUrlQueryString;
        if (this.windowRef.nativeWindow.location.pathname === '/search/find') {
          if (siteLangCode) {
            url.searchParams.append('lang', siteLangCode);
          }
          this.windowRef.nativeWindow.history.pushState({}, '', url.toString());
        } else {