Uploaded image for project: 'ERM Platform'
  1. ERM Platform
  2. ERM-2488

SPIKE: Refactor SearchField

    XMLWordPrintable

Details

    • Tech Debt
    • Status: Open (View Workflow)
    • TBD
    • Resolution: Unresolved
    • None
    • Future Releases, ERM Sprint 157
    • Bienenvolk
    • TBD

    Description

      We appear to have some conflicting and slightly iffy code for ensuring focus on searchField on mount.

       

      In the index files we have a function:

      const focusSearchField = () => {
        const el = document.getElementById(searchInput());
        if (el) {
          el.focus();
        } else {
          history.push(stripes.home);
        }
      };

      Where the `searchInput` method finds the element id from the url. This code alone is slightly ugly looking and could do with some thought, but then we also have the following in those SASQ-rendering route components which have been refactored to functional:

      useEffect(() => {
        if (searchField.current) {
          searchField.current.focus();
        }
      }, []);  // This isn't particularly great, but in the interests of saving time migrating, it will have to do 

      This feels like a repeat of logic, and using a focus within a mount-only useEffect also feels like a race-condition waiting to happen.

       

       

      Some thought is needed on the best way to approach this across our apps.

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                jag.goraya Jag Goraya
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:

                  TestRail: Runs

                    TestRail: Cases