Autocomplete typeahead for property and type lookups#18
Merged
Conversation
Replace the long property/type <select> dropdowns in the annotation overlay with autocomplete typeaheads, porting LinkedDataHub's typeahead interaction but filtering the already-pooled vocabularies locally and synchronously per keystroke (no SPARQL, no debounce, no ixsl:schedule-action). New src/typeahead.xsl: a stable span[@data-field] wrapper swaps between a typing state (input + ul.typeahead-menu) and a committed state (button.typeahead-value + hidden IRI, LDH-style) via result-document literal result elements. Options are prefix-ranked, capped, and bold-highlight the match; keyboard nav mirrors the slash menu; options commit on mousedown (before the input's focusout). local:typeahead-value reads the committed hidden IRI, else a free-typed absolute IRI, else the untouched button->edit value parked on @data-editing-iri (cleared on the first keystroke). Typing a full IRI is accepted directly, so the per-field custom-IRI inputs and the urn:rdfa-editor:custom sentinel are dropped for property/type. The datatype field stays a <select> with its sentinel + custom-datatype input and the datatype/lang mutual-exclusion, unchanged. Dead local:vocab-options and local:ontology-label removed from vocab.xsl. Tests: adapted datatype/features/editor/tables suites to drive the typeahead via a shared typeahead-helper.mjs; the features lint test keeps term-unresolvable via the retained datatype free-text input. New tests/browser/typeahead.mjs covers filter, keyboard/mouse select, free-IRI entry, non-IRI rejection, edit-prefill button, and stale-selection invalidation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What & why
The annotation overlay exposed ontology terms as two long
<select>dropdowns —property(FOAF + DCMI properties) andtypeof(classes), 160+ options each. Scanning them to find a term is slow. This replaces them with autocomplete typeaheads.LinkedDataHub solves this with a typeahead, but its lookups fire debounced SPARQL. RDFa-Editor already prefetches every vocabulary into the SaxonJS document pool (
doc()resolves synchronously), so this ports LDH's interaction while filtering a local in-memory list per keystroke — no async, no debounce, noixsl:schedule-action.Design
src/typeahead.xsl— a stable wrapperspan[@data-field]holds one of two states, swapped viaresult-documentliteral result elements (the IXSL-idiomatic DOM build):input.typeahead-input+ul.typeahead-menubutton.typeahead-value(label + hidden input carrying the IRI, LDH-style button swap)local:vocab-terms(prefix-ranked, capped at 50, matched substring bold-highlighted). Keyboard nav mirrors the slash menu (Arrow/Enter/Escape, first option pre-selected). Options commit onixsl:onmousedown— before the input'sfocusout— with option childrenpointer-events:noneso the<li>is always the event target.local:typeahead-valuereads the committed hidden IRI, else a free-typed absolute IRI (local:is-absolute-iri), else the untouched button→edit value parked on@data-editing-iri(cleared on the first keystroke — the stale-selection guard). Typing/pasting a full IRI is accepted directly, so the per-field custom-IRI inputs and theurn:rdfa-editor:customsentinel are dropped for property/type.datatypestays a<select>(short XSD list) with its sentinel +custom-datatypeinput and the datatype↔lang mutual-exclusion — unchanged.local:vocab-optionsandlocal:ontology-labelremoved fromvocab.xsl.Tests
datatype/features/editor/tablessuites to drive the typeahead via a sharedtests/browser/typeahead-helper.mjs. Thefeatureslint test keepsterm-unresolvablecoverage by routing the bare term through the retained datatype free-text input.tests/browser/typeahead.mjs(17 assertions): filter narrows the list, ArrowDown+Enter commits, mouse-select commits, free-IRI entry, non-IRI rejection, edit-prefill renders the committed button, input focuses on re-edit, and stale-selection invalidation.Verification
🤖 Generated with Claude Code