-
Notifications
You must be signed in to change notification settings - Fork 3.8k
refactor(ui): share field disclosures and icon action geometry #8038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BillLeoutsakosvl346
merged 11 commits into
codex/control-fix-icon-button-sizing
from
codex/control-fix-field-disclosures
Sep 24, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d583476
improvement(emcn): share ordinary action geometry in Button
f472cbb
improvement(ui): share additional-field disclosures
2365885
fix(ui): preserve tiny actions and use shared sidebar geometry
7bf8fe3
improvement(ui): use shared geometry for standard icon actions (#8153)
BillLeoutsakosvl346 11bc7b0
Merge icon button sizing into field disclosures
codex f64118f
refactor(ui): centralize overlay action buttons in EMCN (#7990)
BillLeoutsakosvl346 4a3986b
improvement(ui): reuse shared button and focus treatments (#8187)
BillLeoutsakosvl346 084ce5a
fix(ui): make closed table sidebars inert and strengthen focus ring
bb028dd
Carry code search overlay into the live EMCN stack (#8275)
BillLeoutsakosvl346 cc2699e
fix(ui): announce code search result changes
9c29e80
docs(ui): describe shared table sidebar exports
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
...m/app/workspace/[workspaceId]/components/code-search-overlay/code-search-overlay.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| import { act, createRef } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { | ||
| CodeSearchOverlay, | ||
| type CodeSearchOverlayProps, | ||
| } from '@/app/workspace/[workspaceId]/components/code-search-overlay/code-search-overlay' | ||
|
|
||
| let host: HTMLDivElement | ||
| let root: Root | ||
| const inputRef = createRef<HTMLInputElement>() | ||
|
|
||
| const callbacks = { | ||
| onQueryChange: vi.fn(), | ||
| onPrevious: vi.fn(), | ||
| onNext: vi.fn(), | ||
| onClose: vi.fn(), | ||
| } | ||
| const parentClick = vi.fn() | ||
|
|
||
| function renderOverlay(props: Partial<CodeSearchOverlayProps> = {}) { | ||
| act(() => | ||
| root.render( | ||
| <div onClick={parentClick}> | ||
| <CodeSearchOverlay | ||
| className='top-0 right-0' | ||
| inputKind='chip' | ||
| inputRef={inputRef} | ||
| query='error' | ||
| matchCount={3} | ||
| currentMatchIndex={1} | ||
| {...callbacks} | ||
| {...props} | ||
| /> | ||
| </div> | ||
| ) | ||
| ) | ||
| const overlay = host.firstElementChild?.firstElementChild as HTMLDivElement | ||
| const input = overlay.querySelector('input') as HTMLInputElement | ||
| return { overlay, input } | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true | ||
| vi.clearAllMocks() | ||
| host = document.createElement('div') | ||
| document.body.appendChild(host) | ||
| root = createRoot(host) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => root.unmount()) | ||
| host.remove() | ||
| }) | ||
|
|
||
| describe('CodeSearchOverlay', () => { | ||
| it('shares the floating chrome and routes query, navigation, and close actions', () => { | ||
| const { overlay, input } = renderOverlay() | ||
| expect(overlay.className).toContain('h-[34px]') | ||
| expect(overlay.className).toContain('rounded-sm bg-[var(--surface-1)]') | ||
| expect(overlay.className).toContain('top-0 right-0') | ||
| expect(overlay.getAttribute('role')).toBe('presentation') | ||
| expect(inputRef.current).toBe(input) | ||
| expect(input.getAttribute('aria-label')).toBe('Search code') | ||
| expect(input.value).toBe('error') | ||
| expect(overlay.textContent).toContain('2/3') | ||
| const tally = overlay.querySelector('[aria-live="polite"][aria-atomic="true"]') | ||
| expect(tally?.textContent).toBe('2/3') | ||
|
|
||
| const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set | ||
| act(() => { | ||
| setter?.call(input, 'failed') | ||
| input.dispatchEvent(new Event('input', { bubbles: true })) | ||
| }) | ||
| expect(callbacks.onQueryChange).toHaveBeenCalledWith('failed') | ||
| act(() => { | ||
| overlay.querySelector<HTMLButtonElement>('[aria-label="Previous match"]')?.click() | ||
| overlay.querySelector<HTMLButtonElement>('[aria-label="Next match"]')?.click() | ||
| overlay.querySelector<HTMLButtonElement>('[aria-label="Close search"]')?.click() | ||
| }) | ||
| expect(callbacks.onPrevious).toHaveBeenCalledTimes(1) | ||
| expect(callbacks.onNext).toHaveBeenCalledTimes(1) | ||
| expect(callbacks.onClose).toHaveBeenCalledTimes(1) | ||
| expect(parentClick).not.toHaveBeenCalled() | ||
|
|
||
| renderOverlay({ matchCount: 0, currentMatchIndex: 0 }) | ||
| expect(tally?.textContent).toBe('0/0') | ||
| }) | ||
|
|
||
| it('keeps preview search compact in a floating overlay with a usable input ref', () => { | ||
| const { overlay, input } = renderOverlay({ | ||
| inputKind: 'plain', | ||
| className: 'top-10 right-[8px]', | ||
| }) | ||
| expect(overlay.getAttribute('role')).toBe('presentation') | ||
| expect(overlay.className).toContain('top-10 right-[8px]') | ||
| expect(overlay.hasAttribute('data-toolbar-root')).toBe(false) | ||
| expect(input.parentElement?.className).toContain('h-[23px]') | ||
| expect(inputRef.current).toBe(input) | ||
|
|
||
| const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set | ||
| act(() => { | ||
| setter?.call(input, 'preview') | ||
| input.dispatchEvent(new Event('input', { bubbles: true })) | ||
| overlay.querySelector<HTMLButtonElement>('[aria-label="Next match"]')?.click() | ||
| }) | ||
| expect(callbacks.onQueryChange).toHaveBeenCalledWith('preview') | ||
| expect(callbacks.onNext).toHaveBeenCalledTimes(1) | ||
| expect(parentClick).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('retains the attached terminal edge, marker, wider tally, and disabled navigation', () => { | ||
| const { overlay, input } = renderOverlay({ | ||
| appearance: 'attached', | ||
| inputKind: 'plain', | ||
| className: 'top-[30px] right-[8px]', | ||
| query: '', | ||
| matchCount: 0, | ||
| currentMatchIndex: 0, | ||
| }) | ||
| expect(overlay.className).toContain('rounded-b-[4px] border-t-0 bg-[var(--bg)]') | ||
| expect(overlay.getAttribute('data-toolbar-root')).toBe('true') | ||
| expect(overlay.getAttribute('data-search-active')).toBe('true') | ||
| expect(overlay.hasAttribute('role')).toBe(false) | ||
| expect(input.parentElement?.className).toContain('h-[23px]') | ||
| expect(input.parentElement?.className).toContain('w-[94px]') | ||
| expect(input.className).toContain('text-caption') | ||
| expect(overlay.textContent).toContain('No results') | ||
| expect(overlay.querySelector('span.w-\\[58px\\]')).not.toBeNull() | ||
| const previous = overlay.querySelector<HTMLButtonElement>('[aria-label="Previous match"]') | ||
| const next = overlay.querySelector<HTMLButtonElement>('[aria-label="Next match"]') | ||
| const close = overlay.querySelector<HTMLButtonElement>('[aria-label="Close search"]') | ||
| expect(previous?.disabled).toBe(true) | ||
| expect(next?.disabled).toBe(true) | ||
| expect(close?.disabled).toBe(false) | ||
| expect(previous?.className).toContain('-m-1.5') | ||
| expect(previous?.querySelector('svg')?.getAttribute('class')).toContain('size-[14px]') | ||
| act(() => { | ||
| previous?.click() | ||
| next?.click() | ||
| close?.click() | ||
| }) | ||
| expect(callbacks.onPrevious).not.toHaveBeenCalled() | ||
| expect(callbacks.onNext).not.toHaveBeenCalled() | ||
| expect(callbacks.onClose).toHaveBeenCalledTimes(1) | ||
| }) | ||
|
|
||
| it('shows the compact no-results tally for other code panels', () => { | ||
| const { overlay } = renderOverlay({ matchCount: 0, currentMatchIndex: 0 }) | ||
| expect(overlay.textContent).toContain('0/0') | ||
| expect(overlay.getAttribute('data-toolbar-root')).toBeNull() | ||
| expect( | ||
| overlay.querySelector<HTMLButtonElement>('[aria-label="Previous match"]')?.disabled | ||
| ).toBe(true) | ||
| }) | ||
| }) |
100 changes: 100 additions & 0 deletions
100
apps/sim/app/workspace/[workspaceId]/components/code-search-overlay/code-search-overlay.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import type { ChangeEvent, Ref } from 'react' | ||
| import { Button, ChipInput, cn } from '@sim/emcn' | ||
| import { ArrowDown, ArrowUp, X } from '@sim/emcn/icons' | ||
|
|
||
| export interface CodeSearchOverlayProps { | ||
| /** The attached terminal panel has a joined lower edge and wider result tally. */ | ||
| appearance?: 'floating' | 'attached' | ||
| /** Position relative to the owning code panel. */ | ||
| className: string | ||
| /** Logs use the 30px chip field; previews and terminal output use compact search. */ | ||
| inputKind: 'chip' | 'plain' | ||
| inputRef: Ref<HTMLInputElement> | ||
| query: string | ||
| onQueryChange: (query: string) => void | ||
| matchCount: number | ||
| currentMatchIndex: number | ||
| onPrevious: () => void | ||
| onNext: () => void | ||
| onClose: () => void | ||
| } | ||
|
|
||
| /** Shared controls for searching a Code.Viewer without owning its search state. */ | ||
| export function CodeSearchOverlay({ | ||
| appearance = 'floating', | ||
| className, | ||
| inputKind, | ||
| inputRef, | ||
| query, | ||
| onQueryChange, | ||
| matchCount, | ||
| currentMatchIndex, | ||
| onPrevious, | ||
| onNext, | ||
| onClose, | ||
| }: CodeSearchOverlayProps) { | ||
| const attached = appearance === 'attached' | ||
| const inputProps = { | ||
| ref: inputRef, | ||
| type: 'text', | ||
| value: query, | ||
| onChange: (event: ChangeEvent<HTMLInputElement>) => onQueryChange(event.target.value), | ||
| placeholder: 'Search...', | ||
| 'aria-label': 'Search code', | ||
| } as const | ||
| const actionProps = { | ||
| type: 'button' as const, | ||
| variant: 'ghost' as const, | ||
| iconPadding: attached ? ('md' as const) : ('sm' as const), | ||
| className: attached ? '-m-1.5' : undefined, | ||
| } | ||
| const iconClass = attached ? 'size-[14px]' : 'size-[12px]' | ||
|
|
||
| return ( | ||
| <div | ||
| role={attached ? undefined : 'presentation'} | ||
| className={cn( | ||
| 'absolute z-30 flex h-[34px] items-center gap-1.5 border border-[var(--border)] px-1.5 shadow-xs', | ||
| attached ? 'rounded-b-[4px] border-t-0 bg-[var(--bg)]' : 'rounded-sm bg-[var(--surface-1)]', | ||
| className | ||
| )} | ||
| onClick={(event) => event.stopPropagation()} | ||
| data-toolbar-root={attached ? true : undefined} | ||
| data-search-active={attached ? true : undefined} | ||
| > | ||
| {inputKind === 'chip' ? ( | ||
| <ChipInput {...inputProps} className='mr-0.5 w-[94px]' /> | ||
| ) : ( | ||
| <ChipInput {...inputProps} appearance='compactSearch' className='mr-0.5 w-[94px]' /> | ||
| )} | ||
| <span | ||
| aria-live='polite' | ||
| aria-atomic='true' | ||
| className={cn( | ||
| attached ? 'w-[58px] text-xs' : 'min-w-[45px] text-center text-xs', | ||
| matchCount > 0 ? 'text-[var(--text-secondary)]' : 'text-[var(--text-tertiary)]' | ||
| )} | ||
| > | ||
| {matchCount > 0 | ||
| ? `${currentMatchIndex + 1}/${matchCount}` | ||
| : attached | ||
| ? 'No results' | ||
| : '0/0'} | ||
| </span> | ||
| <Button | ||
| {...actionProps} | ||
| onClick={onPrevious} | ||
| disabled={matchCount === 0} | ||
| aria-label='Previous match' | ||
| > | ||
| <ArrowUp className={iconClass} /> | ||
| </Button> | ||
| <Button {...actionProps} onClick={onNext} disabled={matchCount === 0} aria-label='Next match'> | ||
| <ArrowDown className={iconClass} /> | ||
| </Button> | ||
| <Button {...actionProps} onClick={onClose} aria-label='Close search'> | ||
| <X className={iconClass} /> | ||
| </Button> | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.