-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Property Editor UI Picker: Implement fuzzy search #22468
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
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
2bbd99c
extend icons with information from theseaurus
nielslyngsoe c167993
implement new icon search logic
nielslyngsoe fbc5d5c
clean-up data
nielslyngsoe 5b926af
sorting with a backup of the name
nielslyngsoe 4eb7330
refactor into a controller
nielslyngsoe ddd9269
Merge branch 'main' into v17/feature/extend-icon-data
nielslyngsoe b477e12
improve multi word group search
nielslyngsoe 4fda3c9
embed lucide data
nielslyngsoe 7f4ca19
rename tech into technology
nielslyngsoe 15d0b0e
remove paper from dollar
nielslyngsoe d006f3a
implement fuzzy search for property editor UIs
nielslyngsoe 4c5728d
minor style update
nielslyngsoe 27e14d4
improve property editor UI search
nielslyngsoe c356564
improve search
nielslyngsoe 250e6fe
Merge branch 'v17/feature/extend-icon-data' into v17/improvement/prop…
nielslyngsoe 64922d5
improve search data for Property Editor UIs
nielslyngsoe b6b3ade
remove alias search from property editor ui search
nielslyngsoe a607694
add usage keywords
nielslyngsoe 124e403
Property editor Suggestions based on Property Label
nielslyngsoe 22bdb20
related should not show up in search
nielslyngsoe b496b8a
rename to suggestionQuery
nielslyngsoe ead0a7c
update threshold
nielslyngsoe 602c020
Merge branch 'main' into v17/feature/extend-icon-data
nielslyngsoe cb40398
separate name words
nielslyngsoe bf30984
also consider full icon name match
nielslyngsoe e5c5130
better comment
nielslyngsoe c134a15
other approach for full name matches
nielslyngsoe 253cc0e
full icon name search if query contains a -
nielslyngsoe b983ddc
Merge branch 'main' into v17/feature/extend-icon-data
nielslyngsoe e412a28
Merge branch 'main' into v17/feature/extend-icon-data
nielslyngsoe 96f6df2
fix test
nielslyngsoe 2740b47
Merge branch 'v17/feature/extend-icon-data' into v17/improvement/prop…
nielslyngsoe c9dd593
cache all tokens as well
nielslyngsoe 976196b
catch rejection
nielslyngsoe 354253e
resolve feedback
nielslyngsoe df32ab3
handle rejected promise
nielslyngsoe 4a086ef
Merge branch 'main' into v17/improvement/property-editor-ui-search
nielslyngsoe 6fbfbd2
cancel debounce on disconnect
nielslyngsoe 3cdf79c
declare voids
nielslyngsoe d52b557
corrections
nielslyngsoe bd6ca39
back out if no tokens
nielslyngsoe b15f8e1
rename to suggestionQuery
nielslyngsoe b80c8ef
extend keywords
nielslyngsoe ecb5a4d
more keywords for toggle
nielslyngsoe 1ecd28c
more toggle keywords
nielslyngsoe d38c448
append more keywords
nielslyngsoe a2ca5a2
Merge branch 'main' into v17/improvement/property-editor-ui-search
madsrasmussen 1cafca0
remove duplicate
madsrasmussen 3a9fdf3
Fix toggle manifest status keywords
madsrasmussen 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
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
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/core/property-editor/ui-picker-modal/index.ts
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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './property-editor-ui-picker-modal.token.js'; | ||
| export * from './property-editor-ui-search.controller.js'; |
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
177 changes: 177 additions & 0 deletions
177
...ackages/core/property-editor/ui-picker-modal/property-editor-ui-search.controller.test.ts
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,177 @@ | ||
| import { expect } from '@open-wc/testing'; | ||
| import { UmbPropertyEditorUISearchController } from './property-editor-ui-search.controller.js'; | ||
| import { customElement } from '@umbraco-cms/backoffice/external/lit'; | ||
| import { UmbControllerHostElementMixin } from '@umbraco-cms/backoffice/controller-api'; | ||
| import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/property-editor'; | ||
|
|
||
| @customElement('test-property-editor-ui-search-host') | ||
| class UmbTestControllerHostElement extends UmbControllerHostElementMixin(HTMLElement) {} | ||
|
|
||
| function mockUI( | ||
| overrides: Partial<ManifestPropertyEditorUi> & { alias: string; name: string }, | ||
| ): ManifestPropertyEditorUi { | ||
| const { meta, ...rest } = overrides; | ||
| return { | ||
| type: 'propertyEditorUi', | ||
| meta: { | ||
| label: overrides.name, | ||
| icon: 'icon-circle', | ||
| group: 'Common', | ||
| propertyEditorSchemaAlias: 'Umbraco.Plain', | ||
| ...meta, | ||
| }, | ||
| ...rest, | ||
| } as ManifestPropertyEditorUi; | ||
| } | ||
|
|
||
| const mockUIs: Array<ManifestPropertyEditorUi> = [ | ||
| mockUI({ | ||
| alias: 'Umb.PropertyEditorUi.TextBox', | ||
| name: 'Text Box', | ||
| meta: { label: 'Text Box', icon: 'icon-edit', group: 'Common', propertyEditorSchemaAlias: 'Umbraco.TextBox' }, | ||
| }), | ||
| mockUI({ | ||
| alias: 'Umb.PropertyEditorUi.TextArea', | ||
| name: 'Text Area', | ||
| meta: { label: 'Text Area', icon: 'icon-edit', group: 'Common', propertyEditorSchemaAlias: 'Umbraco.TextArea' }, | ||
| }), | ||
| mockUI({ | ||
| alias: 'Umb.PropertyEditorUi.RichText', | ||
| name: 'Rich Text Editor', | ||
| meta: { | ||
| label: 'Rich Text Editor', | ||
| icon: 'icon-browser-window', | ||
| group: 'richContent', | ||
| propertyEditorSchemaAlias: 'Umbraco.RichText', | ||
| }, | ||
| }), | ||
| mockUI({ | ||
| alias: 'Umb.PropertyEditorUi.MediaPicker', | ||
| name: 'Media Picker', | ||
| meta: { | ||
| label: 'Media Picker', | ||
| icon: 'icon-picture', | ||
| group: 'Pickers', | ||
| propertyEditorSchemaAlias: 'Umbraco.MediaPicker3', | ||
| keywords: ['image', 'photo', 'picture'], | ||
| }, | ||
| }), | ||
| mockUI({ | ||
| alias: 'Umb.PropertyEditorUi.ColorPicker', | ||
| name: 'Color Picker', | ||
| meta: { | ||
| label: 'Color Picker', | ||
| icon: 'icon-palette', | ||
| group: 'Pickers', | ||
| propertyEditorSchemaAlias: 'Umbraco.ColorPicker', | ||
| }, | ||
| }), | ||
| ]; | ||
|
|
||
| describe('UmbPropertyEditorUISearchController', () => { | ||
| let host: UmbTestControllerHostElement; | ||
| let controller: UmbPropertyEditorUISearchController; | ||
|
|
||
| beforeEach(() => { | ||
| host = new UmbTestControllerHostElement(); | ||
| controller = new UmbPropertyEditorUISearchController(host); | ||
| controller.setPropertyEditorUIs(mockUIs); | ||
| }); | ||
|
|
||
| it('should return empty array for empty query', async () => { | ||
| expect(await controller.search('')).to.deep.equal([]); | ||
| expect(await controller.search(' ')).to.deep.equal([]); | ||
| }); | ||
|
|
||
| it('should match by label substring', async () => { | ||
| const results = await controller.search('Text Box'); | ||
| expect(results[0].alias).to.equal('Umb.PropertyEditorUi.TextBox'); | ||
| }); | ||
|
|
||
| it('should match by group', async () => { | ||
| const results = await controller.search('pickers'); | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.MediaPicker')).to.be.true; | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.ColorPicker')).to.be.true; | ||
| }); | ||
|
|
||
| it('should include fuzzy matches for typos', async () => { | ||
| const results = await controller.search('texbx'); | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.TextBox')).to.be.true; | ||
| }); | ||
|
|
||
| it('should include fuzzy matches for misspelled group', async () => { | ||
| const results = await controller.search('pickrs'); | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.MediaPicker')).to.be.true; | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.ColorPicker')).to.be.true; | ||
| }); | ||
|
|
||
| it('should return no results for unrelated query', async () => { | ||
| const results = await controller.search('xyznonexistent'); | ||
| expect(results).to.have.length(0); | ||
| }); | ||
|
|
||
| it('should match multiple tokens', async () => { | ||
| const results = await controller.search('color picker'); | ||
| expect(results[0].alias).to.equal('Umb.PropertyEditorUi.ColorPicker'); | ||
| }); | ||
|
|
||
| it('should surface partial matches for multi-word queries where only one token matches a keyword', async () => { | ||
| // "hero" matches nothing, but "image" is an exact keyword on Media Picker. | ||
| // Without partial-token scoring this would return zero matches. | ||
| const results = await controller.search('hero image'); | ||
| expect(results.some((r) => r.alias === 'Umb.PropertyEditorUi.MediaPicker')).to.be.true; | ||
| }); | ||
|
|
||
| it('should abort a prior in-flight search when a new one starts', async () => { | ||
| const many: Array<ManifestPropertyEditorUi> = []; | ||
| for (let i = 0; i < 200; i++) { | ||
| many.push( | ||
| mockUI({ | ||
| alias: `Umb.PropertyEditorUi.Bulk${i}`, | ||
| name: `Bulk ${i}`, | ||
| }), | ||
| ); | ||
| } | ||
| many.push(...mockUIs); | ||
| controller.setPropertyEditorUIs(many); | ||
|
|
||
| const first = controller.search('Text Box'); | ||
| const second = controller.search('Media Picker'); | ||
|
|
||
| let firstError: unknown; | ||
| try { | ||
| await first; | ||
| } catch (err) { | ||
| firstError = err; | ||
| } | ||
| expect((firstError as DOMException)?.name).to.equal('AbortError'); | ||
|
|
||
| const secondResults = await second; | ||
| expect(secondResults[0].alias).to.equal('Umb.PropertyEditorUi.MediaPicker'); | ||
| }); | ||
|
|
||
| it('should abort an in-flight search on destroy', async () => { | ||
| const many: Array<ManifestPropertyEditorUi> = []; | ||
| for (let i = 0; i < 200; i++) { | ||
| many.push( | ||
| mockUI({ | ||
| alias: `Umb.PropertyEditorUi.Bulk${i}`, | ||
| name: `Bulk ${i}`, | ||
| }), | ||
| ); | ||
| } | ||
| many.push(...mockUIs); | ||
| controller.setPropertyEditorUIs(many); | ||
|
|
||
| const pending = controller.search('Text Box'); | ||
| controller.destroy(); | ||
|
|
||
| let error: unknown; | ||
| try { | ||
| await pending; | ||
| } catch (err) { | ||
| error = err; | ||
| } | ||
| expect((error as DOMException)?.name).to.equal('AbortError'); | ||
| }); | ||
| }); |
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.