Skip to content
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

Suggestion for adding an autocomplete text field #5371

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dimer47
Copy link
Contributor

@dimer47 dimer47 commented Nov 13, 2023

WHY

BEFORE - What was wrong? What was happening before this PR?

There were no text type fields with autocomplete.

CleanShot 2023-11-13 at 12 21 41

AFTER - What is happening after this PR?

Added an autocomplete-text field which allows you to enter text and have autocompletion suggested.

HOW

How did you achieve that, in technical terms?

I took the text field and added the jquery ui load already present in the project to allow autocomplete.

I did not modify the text field because I do not think that this is a behavior that should be able to be activated on a text field. This is a very specific use in my opinion which is only used when needed.

Is it a breaking change?

No, just a suggestion for an addition.

CRUD::field('sound')
             ->type('autocomplete-text')
             ->options(["pushover", "bike", "bugle", "cashregister", "classical", "cosmic", "falling", "gamelan", "incoming", "intermission", "magic", " mechanical", "pianobar", "siren", "spacealarm", "tugboat", "alien", "climb", "persistent", "echo", "updown", "vibrate", "none"]);

How can we test the before & after?

Get the field code and use the autocomplete-text type in its crud, remembering to add a table in the options option.

@jcastroa87
Copy link
Member

Hello @dimer47 , thank you very much for this contribution, one of our members will review this suggestion to evaluate if it meets standards to add it to our main.

Thanks again.

@pxpm
Copy link
Contributor

pxpm commented Nov 21, 2023

I like this idea and the concept of a searchable text field thanks @dimer47 🙏

The code is very clean and it seems to work properly on simpler use cases.

I think this may need a little bit more work to fix edge cases like repeatable such so I don't think we can merge it as is.

I don't want to ask you to work more on this without being 100% sure we are going to do something with it in future. So allow me a few more time when we pick feature to build, to bring this to the team and decide on how to go about this.
For now it's just a file you can place in your /resources/vendor/backpack/crud/fields and use in your projects when you need it.

Will keep this open and re-evaluate in future if we want to spend time doing this as proposed, or we incorporate it as a component later.

Thanks again for the contribution @dimer47 🙏

If anyone feels this is a wanted feature please leave a comment or a thumbs up so that we can prioritize it if more people want it 🙏

Cheers

@promatik
Copy link
Member

Hey @dimer47, @pxpm!

Thank you for the PR, I took a quick check on your code and it looks nice, but it uses jQuery 😅
We're trying to avoid using libraries when they're not needed, and this is a good example.

For this purpose we can use <datalist>, it's vanilla HTML, no javascript needed, and it works just as good, and it's fully supported (https://caniuse.com/?search=datalist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants