The GitLab Jobs location filter dropdown excludes jobs with multiple locations
Describe the Bug
I think I found an issue on the https://about.gitlab.com/jobs/all-jobs page. This is related to the #location-filter-dropdown
location filter dropdown and how jobs are matched to the selected location. Currently only exact matches are returned, but I think both exact and partial matches should be included in the filtered results.
Steps to reproduce:
- Given I visit the GitLab Jobs page
- And I scroll down and see multiple jobs open for a specific location e.g.
Remote, APAC
- And some jobs are open just for the specific location
Remote, APAC
- And some other jobs are open for multiple locations including
Remote, APAC
e.g.Remote, APAC; Remote, Canada; Remote, Europe; Remote, Netherlands; Remote, United Kingdom
- And I select
Remote, APAC
in the locations filter dropdown - Then I see just the
Remote, APAC
exact matches
When no filtered is applied
Remote, APAC
is used in the locations dropdown filter
When
Desired State
When I select a location in the locations filter dropdown I would expect to see both exact and partial location matches, to be more specific Remote, APAC
should match both Remote, APAC
and Remote, APAC; Remote, Canada; Remote, Europe; Remote, Netherlands; Remote, United Kingdom
jobs.
Investigations
I was curios to understand exactly why this happens and did some investigations.
In the curl https://boards-api.greenhouse.io/v1/boards/gitlab/departments | jq
response I can see exactly which of the jobs match and which don't. These two match
...
"internal_job_id": 6216090002,
"location": {
"name": "Remote, APAC"
},
...
"internal_job_id": 6214809002,
"location": {
"name": "Remote, APAC"
},
However this one doesn't
...
"internal_job_id": 6187017002,
"location": {
"name": "Remote, APAC; Remote, Canada; Remote, Europe; Remote, Netherlands; Remote, United Kingdom"
},
So now we know which data is used to filter the input.
Then I used the #location-filter-dropdown
to inspect the source and traced that down to https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/components/jobs/Postings.vue?ref_type=heads#L48 where we can see we try to do an exact match between the lower cased job location name and lowerc ased dropdown value. This will fail to match in case the job location name contains multiple location separated by ;
. Hope i didn't miss anything.
If the expected behaviour is indeed to also return partial matches, I think there are a couple of ways to fix this probably the easiest would be to split the location name by ;
and try to to see if the location drop down value is included in the list, perhaps something like in the attached.
@@ -22,6 +22,8 @@ const { controls, staticJobsData, greenhouseData } = defineProps<Props>();
const location = ref('View all locations');
const expanded = ref<string[]>([]);
+const normalize = (s) => (s ?? '').normalize('NFKC').toLowerCase().trim();
+const matchesSelectedLocation = (name, selected) => String(name).split(';').map(normalize).includes(normalize(selected));
const processJobsData = computed(() => {
if (!staticJobsData || !greenhouseData) return [];
@@ -52,7 +54,7 @@ const filteredContent = computed(() => {
jobListings: department.jobListings
? department.jobListings.map((item) => ({
...item,
- jobs: item.jobs.filter((job) => job.location.name.toLowerCase() === location.value.toLowerCase()),
+ jobs: item.jobs.filter((job) => matchesSelectedLocation(job.location?.name, location.value)),
}))
: [],
})),
I figured this is worth brining up since jobs open to multiple locations will currently never show up if a location is selected in the drop down filter, right now I think that's a total of 36 roles.
curl https://boards-api.greenhouse.io/v1/boards/gitlab/departments | jq '[.departments[].jobs[]?] | {single_location: map(select(.location.name | contains(";") | not)) | length, multiple_locations: map(select(.location.name | contains(";"))) | length}'
{
"single_location": 66,
"multiple_locations": 36
}
Hope that makes sense, let me know if there anything I can help with! Thanks!
What's my browser?
https://www.whatsmybrowser.org/b/WT7R3
Page(s)
Which page(s) have this bug