Skip to content

Add advanced search options to user profile#4012

Merged
mathjazz merged 9 commits intomozilla:mainfrom
flodolo:issue4008
Mar 10, 2026
Merged

Add advanced search options to user profile#4012
mathjazz merged 9 commits intomozilla:mainfrom
flodolo:issue4008

Conversation

@flodolo
Copy link
Collaborator

@flodolo flodolo commented Mar 5, 2026

Fixes #4008

The Python part feels straightforward, the front-end not so much (likely because of my lack of love for JS and React).

One surprise was the amount of places where we hardcoded a default false value for these settings. I tried to define them in one place, so we can change them more easily in the future (well, one for Python and one for JS).

Profile settings are also used on the new /search page.

Screenshot 2026-03-05 alle 06 27 06

@flodolo flodolo requested a review from mathjazz March 5, 2026 05:27
@flodolo flodolo force-pushed the issue4008 branch 3 times, most recently from c266da1 to 43bd307 Compare March 5, 2026 17:46
Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes made in the frontend should also be stored in the DB, otherwise the behaviour is inconsistent with how editor settings work.

I haven't looked at all the code yet.

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 5, 2026

The changes made in the frontend should also be stored in the DB, otherwise the behaviour is inconsistent with how editor settings work.

Not sure I agree on this? That behavior would be very annoying for these settings.

For example: I want to include IDs by default. For a specific search, I go in the menu and disable them. I shouldn't have to then click the menu again to restore my default preference.

Also, I think the menu should reflect the current options coming from the URL (e.g. all-resources/?search=new-tab&string=6430 shouldn't show any option selected), not my profile default. The current code seems to have a bug around that, at least in some cases 🤔

@mathjazz
Copy link
Collaborator

mathjazz commented Mar 5, 2026

Also, I think the menu should reflect the current options coming from the URL (e.g. all-resources/?search=new-tab&string=6430 shouldn't show any option selected), not my profile default.

Ah, that's a good point. Let's keep it that way.

I would add a link to setting, though. And redesign the search menu accordingly:
Posnetek zaslona 2026-03-05 ob 21 47 53

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 6, 2026

Not sure if I took it too far 😓

Given there is no APPLY SEARCH OPTIONS button anymore, when you click one of the options it will perform a new search and close the dropdown.

Screenshot 2026-03-06 alle 06 49 52

Added two commands at the bottom:

  • One to restore your default. That will also perform the search using your defaults. Maybe we could just load the defaults, but I assume you also want to perform a search when you do that. Or maybe I should call that Search with default settings?
  • Open search settings.

Scenarios

Scenario 1

I open translate view, and search for something. This will automatically use my personal defaults. If one of the settings doesn't match Pontoon's default, it will encode the parameter in the URL, so I can share it with other users.
The dropdown also reflects my personal defaults.

As an example, I set my default to include string identifiers. When I search for new-tab, the URL will be http://localhost:8000/it/firefox/all-resources/?search_identifiers=true&search=new-tab&string=6430.

Scenario 2

I load a URL with a search, e.g. http://localhost:8000/it/firefox/all-resources/?search=new-tab. The menu will show Pontoon's default, and will use them for the search.

For example, if I open http://localhost:8000/it/firefox/all-resources/?search=new-tab&string=6430, all search options will be disabled.

If I open http://localhost:8000/it/firefox/all-resources/?search_identifiers=true&search_match_case=true&search=new-tab&string=6430, two options (match case, include IDs) will be selected.

@mathjazz
Copy link
Collaborator

mathjazz commented Mar 9, 2026

Given there is no APPLY SEARCH OPTIONS button anymore, when you click one of the options it will perform a new search and close the dropdown.

This is not an ideal UX. If you click the wrong button, or just want to switch between options, the interaction cost to make a change is high. I would keep the current behaviour and possibly restore the button.

One to restore your default. That will also perform the search using your defaults. Maybe we could just load the defaults, but I assume you also want to perform a search when you do that. Or maybe I should call that Search with default settings?

I like the restore to default entry. But you don't see what the defaults are if you click on it, so triggerring search immediatelly is (like above) not the best UX.

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 9, 2026

I would keep the current behaviour and possibly restore the button.

If clicking an option doesn't trigger the search, I can't see a way without the button. If I click around with the mouse, I don't want to have to click in the field and then switch to keyboard to press enter to start the search.

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 9, 2026

Note: still trying to tidy things up, because I feel like I might have introduced unnecessary duplication or complexity through all the back and forth. Will re-flag for review once ready and tested.

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job - it works great.

Left a couple of comments.

Please apply these changes to the CSS and then I'll take another pass at the frontend code.

/* translate.css | http://localhost:8000/static/translate.css */

.search-panel {
  & .search-button {
    width: 100%;
    line-height: 22px;
    padding: 3px;
  }
  & .menu {
    & li {
      &.action-item {
        /* padding: 4px 2px; */
        padding: 2px 4px;
      }
      /* padding: 4px 2px; */
      padding: 2px 4px;
      line-height: 22px;
    }
  }
  & .visibility-switch {
    & .fa-caret-down {
      /* transform: translate(35%, -25%); */
      transform: translate(40%, -25%);
    }
  }
}

& .fas {
  /* margin-left: 1px; */
  margin-left: -5px;
}

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Seems like these changes are not applied yet. Since they are not directly related to the PR, I can also land them separately:

/* translate.css | http://localhost:8000/static/translate.css */

.search-panel {
  & .visibility-switch {
    & .fa-caret-down {
      /* transform: translate(35%, -25%); */
      transform: translate(40%, -25%);
    }
  }
}

& .fas {
  /* margin-left: 1px; */
  margin-left: -5px;
}

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 10, 2026

LGTM

Seems like these changes are not applied yet. Since they are not directly related to the PR, I can also land them separately:

/* translate.css | http://localhost:8000/static/translate.css */

.search-panel {
  & .visibility-switch {
    & .fa-caret-down {
      /* transform: translate(35%, -25%); */
      transform: translate(40%, -25%);
    }
  }
}

& .fas {
  /* margin-left: 1px; */
  margin-left: -5px;
}

I didn't scroll down 🤦🏼

@flodolo
Copy link
Collaborator Author

flodolo commented Mar 10, 2026

Updated CSS, let me know if I missed anything else.

@flodolo flodolo self-assigned this Mar 10, 2026
Co-authored-by: Matjaž Horvat <matjaz.horvat@gmail.com>
@flodolo
Copy link
Collaborator Author

flodolo commented Mar 10, 2026

Are the options too cramped compared to the 2 commands at the bottom?

Screenshot 2026-03-10 alle 15 09 59

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks!

@mathjazz mathjazz merged commit 9e10cdb into mozilla:main Mar 10, 2026
8 checks passed
@flodolo flodolo deleted the issue4008 branch March 10, 2026 14:12
@mathjazz
Copy link
Collaborator

That's what you just fixed in your latest attempt :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add advanced search options to user profile

2 participants