diff options
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -3072,15 +3072,24 @@ function lockBtn() { // Find anyone on nostr from the header — results open their profile. // Wide screens trade the search icon for a field in the header or sticky // wallet sidebar. It drives the search page, which drops its own copy. +// On a profile the field searches that person's posts: their chip sits in +// it (× or Backspace on an empty field searches everywhere again). function headerSearch() { if (!featureHook('userSearchAvailable')) return null; - return h('input', { - type: 'text', class: 'header-search', placeholder: t('searchUsers') + '…', 'aria-label': t('searchUsers'), - value: (ui.userSearch && ui.userSearch.q) || '', autocapitalize: 'none', autocomplete: 'off', spellcheck: 'false', - onInput: (e) => { clearFeatureNavKeepSearch(); featureHook('userSearchQuery', e.target.value); }, + const chip = featureHook('userSearchScopeChip'); + const input = h('input', { + type: 'text', class: chip ? 'header-search-field' : 'header-search', + placeholder: chip ? t('searchScopedHint') : t('searchUsers') + '…', 'aria-label': t('searchUsers'), + // a profile on screen starts a fresh query; the old one waits behind Back + value: (!ui.profilePk && ui.userSearch && ui.userSearch.q) || '', autocapitalize: 'none', autocomplete: 'off', spellcheck: 'false', + onInput: (e) => { featureHook('userSearchHoldScope'); clearFeatureNavKeepSearch(); featureHook('userSearchQuery', e.target.value); }, // Enter without picking a suggestion: full-text search over notes - onKeydown: (e) => { if (e.key === 'Enter' && !e.isComposing && e.target.value.trim()) { e.preventDefault(); featureHook('userSearchSubmit', e.target.value); e.target.blur(); } }, + onKeydown: (e) => { + if (e.key === 'Enter' && !e.isComposing && e.target.value.trim()) { e.preventDefault(); featureHook('userSearchSubmit', e.target.value); e.target.blur(); } + else if (e.key === 'Backspace' && !e.target.value && chip) { e.preventDefault(); featureHook('userSearchUnscope'); } + }, }); + return chip ? h('div', { class: 'header-search header-search-scoped' }, chip, input) : input; } // Typing in the header field: whatever page is open steps aside for the // results, but the search itself (its query and rows) stays. It used to do @@ -3102,8 +3111,9 @@ function searchBtn() { title: t('searchUsers'), 'aria-label': t('searchUsers'), onClick: () => { + const scope = featureHook('userSearchScopePk'); // from a profile: search inside its person's posts clearFeatureNav(); ui.screen = 'wallet'; - featureHook('openUserSearch'); + featureHook('openUserSearch', scope); render(); setTimeout(() => document.querySelector('.user-search-input')?.focus(), 60); }, |
