: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix: tags (#71869)
Alex V89a856d5ee8f
diff --git a/frontend/src/lib/components/ObjectTags/ObjectTags.removal.test.tsx b/frontend/src/lib/components/ObjectTags/ObjectTags.removal.test.tsxnew file mode 100644index 000000000000..1b83183332aa--- /dev/null+++ b/frontend/src/lib/components/ObjectTags/ObjectTags.removal.test.tsx@@ -0,0 +1,24 @@+import { render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'++import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'++describe('ObjectTags', () => {+ it('removes a tag via the x without collapsing edit mode', async () => {+ const onChange = jest.fn()+ render(+ <ObjectTags tags={['alpha', 'beta']} onChange={onChange} saving={false} tagsAvailable={['alpha', 'beta']} />+ )++ await userEvent.click(screen.getByText('Edit tags'))++ const closeButtons = document.querySelectorAll('.LemonSnack__close button')+ expect(closeButtons).toHaveLength(2)++ await userEvent.click(closeButtons[0] as HTMLElement)++ // The click must actually remove the tag (not just close editing before it lands)+ expect(onChange).toHaveBeenCalledWith(['beta'])+ expect(document.querySelector('input[type="text"]')).not.toBeNull()+ })+})diff --git a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsxindex 2b9003e537b5..0a2c0c5ec130 100644--- a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx+++ b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx@@ -13,6 +13,7 @@ import { LemonCheckbox, Tooltip } from '@posthog/lemon-ui'import { AutoSizer } from 'lib/components/AutoSizer'import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortcut'+import { CLICK_OUTSIDE_BLOCK_CLASS } from 'lib/hooks/useOutsideClickHandler'import { SortableDragIcon } from 'lib/lemon-ui/icons'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { LemonSnack } from 'lib/lemon-ui/LemonSnack/LemonSnack'@@ -1121,7 +1122,7 @@ function DraggableValueSnack<T = string>({// eslint-disable-next-line react/forbid-dom-propsstyle={style}{...attributes}- className="inline-flex text-primary-alt max-w-full overflow-hidden break-all items-center py-1 leading-5 bg-accent-highlight-secondary rounded"+ className={`inline-flex text-primary-alt max-w-full overflow-hidden break-all items-center py-1 leading-5 bg-accent-highlight-secondary rounded ${CLICK_OUTSIDE_BLOCK_CLASS}`}><spanclassName="shrink-0 flex items-center pl-1 pr-0.5 cursor-grab active:cursor-grabbing"@@ -1220,7 +1221,9 @@ function ValueSnacks<T = string>({title={option?.label}onClose={onClose ? () => onClose(value) : undefined}onClick={onInitiateEdit ? () => onInitiateEdit(value) : undefined}- className="cursor-text"+ // Snacks live in the input's prefix (outside floating-ui's reference node), so a click on the+ // remove button reads as an outside press and dismisses/blurs the field before the click lands.+ className={`cursor-text ${CLICK_OUTSIDE_BLOCK_CLASS}`}>{option?.labelComponent ?? option?.label}</LemonSnack>