mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-15 10:59:32 +01:00
fix(custom-model): keep the picker search box unfocused on touch devices
Round-four review item 4: focusing the search input on every picker open raises the OS keyboard over the list on phones; guard it the way readmymind-ui.js does.
This commit is contained in:
1 parent
181e419644
commit
2cc5f3f9e6
2 files changed
+27
-1
No files matched your search
@@ -1106,7 +1106,12 @@ Object.assign(CodemanApp.prototype, {
|
||||
const search = document.getElementById('customModelPickSearch');
|
||||
if (search) {
|
||||
search.value = '';
|
||||
search.focus();
|
||||
// readmymind-ui.js's rule: on touch devices never focus an input unprompted, or
|
||||
// the OS keyboard pops over the very list the picker just opened to show. Desktop
|
||||
// keeps the caret in the box, one keystroke from filtering.
|
||||
if (!(typeof MobileDetection !== 'undefined' && MobileDetection.isTouchDevice())) {
|
||||
search.focus();
|
||||
}
|
||||
}
|
||||
this.filterCustomModelPick('');
|
||||
},
|
||||
|
||||
@@ -564,6 +564,27 @@ describe('Custom Model Endpoint Profiles: the "which model" picker', () => {
|
||||
expect(visible).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('leaves the search box unfocused on touch devices so the OS keyboard stays off the list', async () => {
|
||||
const { win, app } = bootApp({
|
||||
hosts: [{ id: 'llama-box', label: 'llama.cpp', baseUrl: 'http://x', models: ['qwen3', 'llama3'] }],
|
||||
});
|
||||
win.app = app;
|
||||
// The guard reads the global the browser defines (mobile-detection.js).
|
||||
(win as unknown as { MobileDetection: { isTouchDevice: () => boolean } }).MobileDetection = {
|
||||
isTouchDevice: () => true,
|
||||
};
|
||||
|
||||
await app.selectCustomModelEntry('claude', 'llama-box');
|
||||
|
||||
const search = win.document.getElementById('customModelPickSearch') as HTMLInputElement;
|
||||
expect(win.document.activeElement).not.toBe(search);
|
||||
// Only the focus is skipped: the rows still render, unfiltered and functional.
|
||||
const visible = [...win.document.getElementById('customModelPickList')!.querySelectorAll('button')].filter(
|
||||
(b) => !b.hasAttribute('hidden')
|
||||
);
|
||||
expect(visible).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('filters rows case-insensitively on the model id, keeping the surviving row fully functional', async () => {
|
||||
const { win, app } = bootApp({
|
||||
hosts: [
|
||||
|
||||
Reference in new issue
Block a user