Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Discuss
  3. Add a way to clear app search more easily

Add a way to clear app search more easily

Scheduled Pinned Locked Moved Discuss
7 Posts 3 Posters 34 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic was forked from Cloudron 9.0 (beta) bug reports nebulon
This topic has been deleted. Only users with topic management privileges can see it.
  • humptydumptyH Offline
    humptydumptyH Offline
    humptydumpty
    wrote last edited by humptydumpty
    #1

    One more suggestion if I may. Clear the search box when you click on the logo in the top left.

    Use case: You search for an app. To see the rest of your apps, you have to delete what you searched for or refresh the page which has a "reload" time and isn't instant. Clearing the input search box by pressing on the logo is faster and feels more natural.

    image.png

    Edit: Chatgpt spat out this code, don't shoot me 🙂

    Clear search when clicking the Cloudron logo

    // Clears the dashboard search field on logo click or ESC key
    function enableClearSearchIntegration() {
      const searchInput = document.querySelector('input.pankow-text-input[placeholder="Search Apps"]');
      const logo = document.querySelector('.sidebar-logo');
    
      if (!searchInput) return;
    
      // ---- LOGO CLICK HANDLER ----
      if (logo && !logo.dataset._cloudronClearSearch) {
        logo.dataset._cloudronClearSearch = "1";
    
        logo.addEventListener("click", () => {
          clearSearch(searchInput);
        }, true);
      }
    
      // ---- ESC KEY HANDLER ----
      if (!window._cloudronClearSearchEsc) {
        window._cloudronClearSearchEsc = true;
    
        document.addEventListener("keydown", (event) => {
          if (event.key === "Escape") {
            clearSearch(searchInput);
          }
        });
      }
    }
    
    // Clears the input and triggers Cloudron filtering
    function clearSearch(searchInput) {
      searchInput.value = "";
      searchInput.dispatchEvent(new Event("input", { bubbles: true }));
      searchInput.dispatchEvent(new Event("change", { bubbles: true }));
    }
    
    // Run once on initial load
    enableClearSearchIntegration();
    
    // Re-run when the SPA updates the DOM (Cloudron dashboard is an SPA)
    const observer = new MutationObserver(enableClearSearchIntegration);
    observer.observe(document.body, { childList: true, subtree: true });
    
    

    Edit 2: fixed the code as we didn't use the right class selector for the logo. I tested it in the console and the code works as intended!
    Edit 3: fixed the code again to use the proper selector for the search box. NOW it's ready 🙂
    Edit 4: added support for escape key clear action thanks @robi

    Recording 2025-12-03 160333.gif

    robiR 1 Reply Last reply
    0
    • humptydumptyH humptydumpty

      One more suggestion if I may. Clear the search box when you click on the logo in the top left.

      Use case: You search for an app. To see the rest of your apps, you have to delete what you searched for or refresh the page which has a "reload" time and isn't instant. Clearing the input search box by pressing on the logo is faster and feels more natural.

      image.png

      Edit: Chatgpt spat out this code, don't shoot me 🙂

      Clear search when clicking the Cloudron logo

      // Clears the dashboard search field on logo click or ESC key
      function enableClearSearchIntegration() {
        const searchInput = document.querySelector('input.pankow-text-input[placeholder="Search Apps"]');
        const logo = document.querySelector('.sidebar-logo');
      
        if (!searchInput) return;
      
        // ---- LOGO CLICK HANDLER ----
        if (logo && !logo.dataset._cloudronClearSearch) {
          logo.dataset._cloudronClearSearch = "1";
      
          logo.addEventListener("click", () => {
            clearSearch(searchInput);
          }, true);
        }
      
        // ---- ESC KEY HANDLER ----
        if (!window._cloudronClearSearchEsc) {
          window._cloudronClearSearchEsc = true;
      
          document.addEventListener("keydown", (event) => {
            if (event.key === "Escape") {
              clearSearch(searchInput);
            }
          });
        }
      }
      
      // Clears the input and triggers Cloudron filtering
      function clearSearch(searchInput) {
        searchInput.value = "";
        searchInput.dispatchEvent(new Event("input", { bubbles: true }));
        searchInput.dispatchEvent(new Event("change", { bubbles: true }));
      }
      
      // Run once on initial load
      enableClearSearchIntegration();
      
      // Re-run when the SPA updates the DOM (Cloudron dashboard is an SPA)
      const observer = new MutationObserver(enableClearSearchIntegration);
      observer.observe(document.body, { childList: true, subtree: true });
      
      

      Edit 2: fixed the code as we didn't use the right class selector for the logo. I tested it in the console and the code works as intended!
      Edit 3: fixed the code again to use the proper selector for the search box. NOW it's ready 🙂
      Edit 4: added support for escape key clear action thanks @robi

      Recording 2025-12-03 160333.gif

      robiR Offline
      robiR Offline
      robi
      wrote last edited by
      #2

      @humptydumpty use if the Esc key is also a good way.

      Conscious tech

      humptydumptyH 1 Reply Last reply
      1
      • robiR robi

        @humptydumpty use if the Esc key is also a good way.

        humptydumptyH Offline
        humptydumptyH Offline
        humptydumpty
        wrote last edited by
        #3

        @robi code revised and escape key support added 🙂

        1 Reply Last reply
        1
        • nebulonN Offline
          nebulonN Offline
          nebulon
          Staff
          wrote last edited by nebulon
          #4

          I think the ESC key clearing search is a good idea.

          The generated code above though, while probably working, is not a good solution. It clearly has no clue how the app is actually developed, using vue components. It just operates on the resulting DOM output from vuejs, which would be very fragile (vuejs deletes/creates DOM nodes based on a virutal DOM, so the referenced DOM nodes may or may not exist when events fire, if written like that) and requires monkey patching like the DOM mutation observers, which is impossible to properly maintain. But its a good way for a proof of concept or playground 😄

          humptydumptyH 1 Reply Last reply
          2
          • nebulonN nebulon

            I think the ESC key clearing search is a good idea.

            The generated code above though, while probably working, is not a good solution. It clearly has no clue how the app is actually developed, using vue components. It just operates on the resulting DOM output from vuejs, which would be very fragile (vuejs deletes/creates DOM nodes based on a virutal DOM, so the referenced DOM nodes may or may not exist when events fire, if written like that) and requires monkey patching like the DOM mutation observers, which is impossible to properly maintain. But its a good way for a proof of concept or playground 😄

            humptydumptyH Offline
            humptydumptyH Offline
            humptydumpty
            wrote last edited by humptydumpty
            #5

            1 Reply Last reply
            0
            • nebulonN Offline
              nebulonN Offline
              nebulon
              Staff
              wrote last edited by
              #6

              Please do not dump AI output in the forum, this adds a bit too much noise, it is very far from how the code is structured also. It all just very hypothetical and might even be wrong in details unless vetted.

              1 Reply Last reply
              2
              • nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote last edited by
                #7

                The fix for this to clear the search filter on ESC if the view is active: https://git.cloudron.io/platform/box/-/commit/425e196dfc4f4c7e31870f36df7cab0417f7a523

                1 Reply Last reply
                2
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Bookmarks
                • Search