Search for tag with checkbox on mobile

If I visit Topics tagged theme-component on moblie, tap the magnifying glass, search e.g. for “topic” and tap the checkbox to “search the tag #theme-component”, there are two problems.
On the one hand you need to tap the checkbox twice untill the box is checked. On the other hand there are no search results after tapping the checkbox once or twice, while there are many, if you use the desktop search.

Searching on mobile without touching the checkbox


https://meta.discourse.org/search?context=tag&context_id=theme-component&q=Topic&skip_context=true

Searching on mobile & tapped checkbox once


https://meta.discourse.org/search?context=tag&context_id=theme-component&q=Topic&skip_context=false

Searching on mobile & tapped checkbox twice


https://meta.discourse.org/search?context=tag&context_id=theme-component&q=Topic&skip_context=false

Searching using desktop-view


https://meta.discourse.org/search?q=topic%20%23theme-component

I know, I could type the #theme-component into the search to get results on moblie, but I think that’s not the idea of offering the checkbox.

3 Likes

Hey, good catch @moin. I think you may have found two bugs. :slight_smile:

  1. The checkbox doesn’t work immediately, and
  2. Scoping search to a tag creates a route that Discourse serves with a 403

Checkbox isn’t checking

In the mobile the search link adds “context” to the URL, which reveals the checkbox to be toggled in question. In this case, the URL we are looking at is https://meta.discourse.org/search?context=tag&context_id=theme-component&skip_context=true.

When we toggle the checkbox, we are changing the search query where skip_context changes from true to false and back again. It also means you may craft a URL where the box is checked by default, such as https://meta.discourse.org/search?context=category&context_id=1&skip_context=false. This is important, because I’ve noticed different behaviour between the two states when they load.

skip_context=true

The default on mobile view, and the box will not be checked. Interacting with the checkbox, with touch or keyboard, changes the URL to skip_context=false, but does not check the checkbox. Clicking once more will check it, keeping “false” in the URL.

Afterward it may be toggled back and forth, with corresponding URL changes as expected.

skip_context=false

When the search is loaded the checkbox is checked, and interacting with it works as expected: each interaction changes the checkbox and the URL.


I’ve noticed separately that using those checkboxes also causes me to lose focus on the page, regardless of the skip_context value; hopefully it’s the same thing causing our double-click issue. :slight_smile:

I’ve reproduced this behavior in safe-mode and on mobile devices.

Okay, I’ll see what I can explain about the tags not scoping in a follow up reply, so it’s easier to split off it needed.

3 Likes

Scoping of tags in search returns 403

This one threw me off, because when I tried to reproduce it off meta I accidentially loaded a category rather than a tag in the search context. That was fortunate, as when I realized my mistake I at least knew how the search queries are being produced for those contexts.

Using #theme and #theme-component for examples:

When we use the search context for tags our request looks like https://meta.discourse.org/search?q=topic&page=1&search_context[type]=tag&search_context[id]=theme-component, which returns 403.

When we use search context for categories, our request looks like https://meta.discourse.org/search?q=topic&page=1&search_context[type]=category&search_context[id]=61, which returns results as expected.

Alternatively, if we choose a tag from the advanced search filters our request looks like https://meta.discourse.org/search?q=tags:theme-component&page=1 and returns results with that tag.

I’m able to reproduce the &search_context[type]=tag&search_context[id]=theme-component path returning a 403 in safe-mode as well.

Are there other search_context types? I glanced at the code but wasn’t able to determine; if so, we can test them as well.

3 Likes