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

Using an icon font displays unexpected results #358

Open
benlevydesign opened this issue Dec 30, 2017 · 12 comments
Open

Using an icon font displays unexpected results #358

benlevydesign opened this issue Dec 30, 2017 · 12 comments

Comments

@benlevydesign
Copy link

benlevydesign commented Dec 30, 2017

Version of Dropkick:

2.1.7

Expected Behavior

DropKick should work as expected and display the selected option that I'm pulling from my mysql database with <?php echo $vendcat ?> which would have <i class="material-icons">&#xEB47;</i> as one of the results and would output it like: ic_kitchen_black_24dp_1x

I've used DropKick before with just text only options and pulling them with my php/mysql databases. As expected, anywhere else I use the <?php echo $vendcat ?> php code to display the mysql result, I get what I want: ic_kitchen_black_24dp_1x or one of the 2 other choices from the icon font I'm using. You can see it working here (look on the right side after each vendors name).

Actual Behavior

I'm using DropKick and getting the selected option from my mysql database and it works as expected but I'm using an icon font and when using the icons in the select options I just get a small black outlined box like this: 

Here is my test webpage

Here is my DropKick test with select options that use an icon font icon as part of the option text
Look for the "vendor type" DropKick (the form element after "vendor name")

Any help or ideas would be greatly appreciated. I would love to use the select element with DropKick for this form element.

@benlevydesign
Copy link
Author

benlevydesign commented Jan 3, 2018

@Robdel12 or @wwilsman: Any ideas?

Thanks so much!

@Robdel12
Copy link
Owner

Robdel12 commented Jan 5, 2018

Hey @benlevywebdesign! Sorry for the delayed response. I've been in the middle of a move for a week (just got internet back today! :p). I hope to be able to get to this over the weekend though!

@Robdel12 Robdel12 self-assigned this Jan 5, 2018
@benlevydesign
Copy link
Author

No worries, It's probably something so simple I'm missing. I'm not sure though...

@benlevydesign
Copy link
Author

benlevydesign commented Jan 5, 2018

I'm going to try something. It probably won't work, but I'm going to try hosting the icon font myself and see what happens...

@Robdel12
Copy link
Owner

Robdel12 commented Jan 5, 2018

I was thinking about this and I wonder if it's because icon fonts can't be rendered in a normal select. I'm sure there's something in DK we can do to fix that, but I think that's the issue here.

@wwilsman
Copy link
Collaborator

wwilsman commented Jan 5, 2018

I'm betting it has something to do with the innerHTML property. That property parses the html. I think what we'll want is textContent.

There's a few places we reference innerHTML we'll need to replace if this is the case

@benlevydesign
Copy link
Author

benlevydesign commented Jan 5, 2018

Should I try replacing innerHTML with textContent? I would do this in the JS file?

@Robdel12
Copy link
Owner

Robdel12 commented Jan 7, 2018

Just to give an update: in-between unpackings I've tried to reproduce / fix the issue but I haven't been able to even get the icon to render. Curious if this is something older DK can do and not the latest release. (I see you're using 2.1.7)

I tried going brute force and replacing innerHTML with textContent but that breaks DK, haha. I'm going to need to carve out some time for this one.

@benlevydesign
Copy link
Author

Any enlightening discoveries?

@Robdel12
Copy link
Owner

Hey @benlevywebdesign I haven't had time to really dig into this but I do know this will be a tough one to solve. Mainly because icons aren't supported in regular <selects>, which is what DropKick uses to build itself. We'll have to make sure we handle the cases for scrubbing out the icon from the value attribute too.

This should be a feature that we add for sure though.

@benlevydesign
Copy link
Author

benlevydesign commented Jan 26, 2018

Hmm, yeah thats true with regular selects too I supposes. I thought I'd have to insert <i class="material-icons">&#xEB47;</i> into my databse to echo it back on the page but I think the easiest thing to do would be for me to use just text in the select and echo out the result as the icon with some if else statements. I'm not so concerned with having the icon display as the selects element. If you want to mark this issue closed you can.

@Robdel12
Copy link
Owner

I think this is something DropKick should do though. This is a pretty common reason why someone would use a select replacement over a normal select.

Thanks for raising the issue :D

@Robdel12 Robdel12 removed their assignment Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants