diff --git a/changelog.d/1841-kit-search-field.md b/changelog.d/1841-kit-search-field.md
new file mode 100644
index 0000000000..de72045c39
--- /dev/null
+++ b/changelog.d/1841-kit-search-field.md
@@ -0,0 +1,3 @@
+- The Context panel search and the Layer Finder search are now one kit
+ component, `UiSearchField`, with the same look and behaviour as before
+ (manjunath22466, samehkhamis, #1841).
diff --git a/docs/VUE-MIGRATION.md b/docs/VUE-MIGRATION.md
index 24b2e2c63a..26a164b4ae 100644
--- a/docs/VUE-MIGRATION.md
+++ b/docs/VUE-MIGRATION.md
@@ -37,9 +37,9 @@ one-panel rule too. Share links continue to record which panels are open.
## Component kit
`src/ui/kit/` holds the generic components: `UiRail`, `UiTooltip`, `UiIcon`,
-`UiButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`, `UiSelect`,
-`UiBadge` and `UiEmpty` so far, with more joining as the controls they serve
-are converted. One component
+`UiButton`, `UiCloseButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`,
+`UiSelect`, `UiSearchField`, `UiBadge` and `UiEmpty` so far, with more
+joining as the controls they serve are converted. One component
serves every use of a control, with props for the differences (`UiPanel`'s
`sideways`, `glow`, `scroll`), rather than a copy per panel. The components
are styled by the existing stylesheet and custom properties, and they contain
@@ -54,6 +54,7 @@ never copied:
| `UiButton` `variant="primary"` | the action surface with a group's main-action accent | `src/ui/styles/action-button.css` |
| `UiButton` `variant="icon"` | the 22px square glyph button of a panel's collapse toggle | `src/ui/styles/controls.css` |
| `UiCloseButton` | a close, dismiss or clear button: a bare glyph (× with `glyph="times"`, the Material `close` symbol with `glyph="icon"`) with no padding, border or background of its own and a pointer; the site's feature class sets size, colour, hover and any surface, and `bare` leaves the look off for a skin that sets its own padding and border | `src/ui/styles/close-button.css` |
+| `UiSearchField` | a search field: the Material `search` glyph and a search input in a flex row, the input bare (no border or background, free to shrink); the site's feature classes set the frame's size, surface and focus ring and the input's type and outline, and the browser's own cancel button is left to each skin | `src/ui/styles/search-field.css` |
| `UiChip` | the read-only chip (a pill of uppercase mono text); `selected` takes the accent | `src/ui/styles/chip.css` |
| `UiEmpty` | the one-line empty state (dim mono text), its hint on a line below | `src/ui/styles/empty-state.css` |
| `UiBadge` | the read-only badge (`gev-status-badge`) | `src/ui/styles/status-badge.css` |
@@ -107,6 +108,18 @@ clear button in the views is one (`src/ui/kit/closeButtons.test.mjs` pins
it); Street Level's and the space mission's keep `bare`, since their skins
set their own padding and border. The close buttons built in script (credits, the
Quebec CCTV overlay, the guide) are not converted yet.
+`UiSearchField` takes `v-model`, a required `label` (the input's
+accessible name), `placeholder` and `tag` (`div`, given `role="search"` by
+the site, or `label`); attributes and classes go to the frame, and
+`inputId`, `inputClass`, `autocomplete` and `spellcheck` to the input. With
+`clearLabel` it shows a `UiCloseButton` (`clearClass`, its label as its tip)
+while text is typed, which empties the field and focuses the input again.
+Escape stops at the input and is emitted with its event, so a site that also
+keeps the browser from clearing the field prevents it there; `focus()`
+focuses the input. The Context search and the Layer Finder's are
+`UiSearchField`s; the locale picker's combobox, the Omnibar's location
+field and the Data Library's labelled search are other controls. Its kit rules hold the declarations both search
+skins had in common, moved rather than copied, and load before them.
`UiSlider` keeps the native range input rather than drawing a
`role="slider"` track, so Core's keyboard, form behaviour and styling stay;
it takes `v-model`, `min`, `max`, `step` and `disabled`, emits a
diff --git a/scripts/format-scope.json b/scripts/format-scope.json
index 89cb505b82..498850540f 100644
--- a/scripts/format-scope.json
+++ b/scripts/format-scope.json
@@ -1333,6 +1333,9 @@
"src/ui/kit/UiCloseButton.test.mjs",
"src/ui/kit/closeButtons.test.mjs",
"src/ui/styles/close-button.css",
+ "src/ui/kit/UiSearchField.vue",
+ "src/ui/kit/UiSearchField.test.mjs",
+ "src/ui/styles/search-field.css",
"src/ui/styles/chip.css",
"src/ui/styles/empty-state.css",
"src/ui/rail/RailChips.vue",
diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json
index be5b54b3d9..fd7a9b00fc 100644
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@ -242,6 +242,7 @@
"src/ui/kit/UiEmpty.vue",
"src/ui/kit/UiBadge.vue",
"src/ui/kit/UiCloseButton.vue",
+ "src/ui/kit/UiSearchField.vue",
"src/ui/stores/globeActions.js",
"src/ui/views/panels/GlobeActions.vue",
"src/ui/views/panels/RenderFailure.vue",
diff --git a/src/ui/kit/UiSearchField.test.mjs b/src/ui/kit/UiSearchField.test.mjs
new file mode 100644
index 0000000000..5971efcf28
--- /dev/null
+++ b/src/ui/kit/UiSearchField.test.mjs
@@ -0,0 +1,136 @@
+import { after, before, test } from 'node:test';
+import assert from 'node:assert/strict';
+import { installVueDom } from '../../testSupport/vueDom.mjs';
+
+let mount;
+let UiSearchField;
+let uninstall;
+before(async () => {
+ uninstall = installVueDom();
+ ({ mount } = await import('@vue/test-utils'));
+ UiSearchField = (await import('./UiSearchField.vue')).default;
+});
+after(() => uninstall());
+
+/** A field whose v-model writes back into its props, as a parent's would. */
+function bound(props = {}, attrs = {}) {
+ const wrapper = mount(UiSearchField, {
+ attachTo: document.body,
+ props: {
+ label: 'Search layers',
+ modelValue: '',
+ ...props,
+ 'onUpdate:modelValue': (value) => wrapper.setProps({ modelValue: value }),
+ },
+ attrs,
+ });
+ return wrapper;
+}
+
+test('a search field is the search glyph and a search input named by its label', () => {
+ const wrapper = bound({ placeholder: 'Search layers…' });
+ const root = wrapper.get('div');
+ assert.ok(root.classes().includes('ui-search-field'));
+ const icon = wrapper.get('span');
+ assert.equal(icon.text(), 'search');
+ assert.ok(icon.classes().includes('material-symbols-outlined'));
+ assert.equal(icon.attributes('aria-hidden'), 'true');
+ const input = wrapper.get('input');
+ assert.equal(input.attributes('type'), 'search');
+ assert.ok(input.classes().includes('ui-search-field__input'));
+ assert.equal(input.attributes('aria-label'), 'Search layers');
+ assert.equal(input.attributes('placeholder'), 'Search layers…');
+ for (const name of ['id', 'autocomplete', 'spellcheck'])
+ assert.equal(input.attributes(name), undefined, name);
+ assert.equal(wrapper.find('button').exists(), false);
+ wrapper.unmount();
+});
+
+test('v-model shows the text and updates it as typed', async () => {
+ const wrapper = bound({ modelValue: 'radar' });
+ const input = wrapper.get('input');
+ assert.equal(input.element.value, 'radar');
+ await input.setValue('rain');
+ assert.deepEqual(wrapper.emitted('update:modelValue').at(-1), ['rain']);
+ assert.equal(wrapper.props('modelValue'), 'rain');
+ // A parent that empties its value, as closing a search does, empties the input.
+ await wrapper.setProps({ modelValue: '' });
+ assert.equal(input.element.value, '');
+ wrapper.unmount();
+});
+
+test('the clear button shows only while text is typed, clears and refocuses', async () => {
+ const wrapper = bound({
+ clearLabel: 'Clear search',
+ clearClass: 'context-search__clear',
+ });
+ assert.equal(wrapper.find('button').exists(), false);
+ await wrapper.setProps({ modelValue: 'rain' });
+ const clear = wrapper.get('button');
+ assert.equal(clear.attributes('aria-label'), 'Clear search');
+ assert.equal(clear.attributes('title'), 'Clear search');
+ assert.ok(clear.classes().includes('context-search__clear'));
+ assert.ok(clear.classes().includes('ui-close-button'));
+ assert.equal(clear.get('span').text(), 'close');
+ await clear.trigger('click');
+ assert.deepEqual(wrapper.emitted('update:modelValue').at(-1), ['']);
+ assert.equal(document.activeElement, wrapper.get('input').element);
+ assert.equal(wrapper.find('button').exists(), false);
+ wrapper.unmount();
+});
+
+test('Escape is emitted with its event and stops at the input', async () => {
+ const wrapper = bound();
+ let bubbled = 0;
+ const onKey = () => bubbled++;
+ wrapper.element.addEventListener('keydown', onKey);
+ await wrapper.get('input').trigger('keydown', { key: 'Escape' });
+ const escapes = wrapper.emitted('escape');
+ assert.equal(escapes.length, 1);
+ assert.ok(escapes[0][0] instanceof Event);
+ assert.equal(escapes[0][0].defaultPrevented, false);
+ assert.equal(bubbled, 0);
+ await wrapper.get('input').trigger('keydown', { key: 'a' });
+ assert.equal(wrapper.emitted('escape').length, 1);
+ assert.equal(bubbled, 1);
+ wrapper.unmount();
+});
+
+test('tag="label" frames the input in a label', () => {
+ const wrapper = bound({ tag: 'label' });
+ assert.equal(wrapper.element.tagName, 'LABEL');
+ assert.ok(wrapper.element.contains(wrapper.get('input').element));
+ wrapper.unmount();
+});
+
+test('attributes and classes pass through to the frame; the input takes its own', () => {
+ const wrapper = bound(
+ {
+ inputId: 'layer-finder-input',
+ inputClass: 'context-search__input',
+ autocomplete: 'off',
+ spellcheck: 'false',
+ },
+ { class: 'context-search', role: 'search', 'data-x': '1' },
+ );
+ const root = wrapper.get('div');
+ assert.ok(root.classes().includes('context-search'));
+ assert.ok(root.classes().includes('ui-search-field'));
+ assert.equal(root.attributes('role'), 'search');
+ assert.equal(root.attributes('data-x'), '1');
+ const input = wrapper.get('input');
+ assert.equal(input.attributes('id'), 'layer-finder-input');
+ assert.ok(input.classes().includes('context-search__input'));
+ assert.ok(input.classes().includes('ui-search-field__input'));
+ assert.equal(input.attributes('autocomplete'), 'off');
+ assert.equal(input.attributes('spellcheck'), 'false');
+ assert.equal(input.attributes('role'), undefined);
+ wrapper.unmount();
+});
+
+test('focus() focuses the input', () => {
+ const wrapper = bound();
+ wrapper.vm.focus();
+ assert.equal(document.activeElement, wrapper.get('input').element);
+ wrapper.unmount();
+});
diff --git a/src/ui/kit/UiSearchField.vue b/src/ui/kit/UiSearchField.vue
new file mode 100644
index 0000000000..eb969b1fa4
--- /dev/null
+++ b/src/ui/kit/UiSearchField.vue
@@ -0,0 +1,81 @@
+
+
+
+