Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signals): keep trailing spaces in the scouts roster search (#108165)

posthog[bot]16bec60ebe8d
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
index 9004391a5027..b5ea79dbfad3 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
@@ -784,6 +784,30 @@ describe('scoutFleetLogic', () => {
}
})
+ it.each([
+ ['a trailing space', 'checkout ', 'checkout'],
+ ['a trailing space after a number', '123 ', '123'],
+ ['only spaces', ' ', undefined],
+ ])('keeps %s in the search box after the debounced URL write', async (_, typed, written) => {
+ jest.useFakeTimers()
+ try {
+ // The enabled filter keeps a roster param in the URL, so the search write reaches the
+ // shared-link hydration path.
+ router.actions.push(urls.inbox('scouts'), { scoutEnabled: 'enabled' })
+ logic.actions.setScoutSearch(typed)
+ await jest.advanceTimersByTimeAsync(600)
+
+ expect(router.values.searchParams.scoutSearch).toEqual(written)
+ expect(logic.values.scoutSearch).toEqual(typed)
+
+ // The filter controls push the URL, so a push must not trim the search either.
+ logic.actions.setScoutEnabledFilter('disabled')
+ expect(logic.values.scoutSearch).toEqual(typed)
+ } finally {
+ jest.useRealTimers()
+ }
+ })
+
it('keeps the roster filters out of a bare URL that a sibling logic replaces', async () => {
router.actions.push(urls.inbox('scouts'), { scoutEnabled: 'enabled' })
await expectLogic(logic).toDispatchActions(['hydrateRosterFilters'])
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
index de7148e2e2c2..82d11a317694 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts
@@ -1917,9 +1917,11 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
}
// A shared link is authoritative: apply what it carries and reset the rest to defaults.
// Guarded so plain navigation onto the roster does not re-dispatch an unchanged state.
+ // The URL holds the trimmed search, so compare trimmed text. Otherwise the debounced
+ // write of "checkout " hydrates the box back to "checkout" while the user still types.
const parsed = parseRosterFilterSearchParams(searchParams)
if (
- parsed.scoutSearch === values.scoutSearch &&
+ parsed.scoutSearch.trim() === values.scoutSearch.trim() &&
parsed.scoutEnabledFilter === values.scoutEnabledFilter &&
sameTags(parsed.selectedScoutTags, values.selectedScoutTags) &&
parsed.selectedScoutOwner === values.selectedScoutOwner