ember-power-select icon indicating copy to clipboard operation
ember-power-select copied to clipboard

allowClear button gone with selectedItemComponent

Open matthellstrom opened this issue 8 years ago • 12 comments

In looking through this site, it seems like the selectedItemComponent just replaces the text in the trigger, and shouldn't hide the allowClear "x", but I can't see it.

My component is simple, just something like this: <div> {{option.firstname}} {{option.lastname}} </div>

If I put nothing in the component hbs, the allowClear "x" does show. It seems like my text is covering it up.

Am I doing something wrong?

matthellstrom avatar Apr 10 '17 21:04 matthellstrom

No, you're not. The key thing is that this button is actually outside that component, it is part of the trigger. That is the component you must customize to remove it.

It's less dauting that it seems tho. Import and export the original trigger without changing a comma:

import EmberPowerSelectMultipleTrigger from 'ember-power-select/components/power-select-multiple/trigger';
export default EmberPowerSelectMultipleTrigger.extend();

And make that component's template be a copy-paste of the original template with the the changes you want (no buttons)

cibernox avatar Apr 10 '17 22:04 cibernox

Actually, I want the allowClear button and it's not showing. This is on a single select, not a multiple select.

matthellstrom avatar Apr 10 '17 22:04 matthellstrom

All, I misread it. Are you passing allowClear=true? The logic to show that button is pretty simple: https://github.com/cibernox/ember-power-select/blob/master/addon/templates/components/power-select/trigger.hbs#L7

cibernox avatar Apr 10 '17 22:04 cibernox

Yes, here's my code:

	{{#power-select 
			placeholder="Select User..." 
			selected=selectedUser
			selectedItemComponent="order-user-trigger"
			disabled=(not orderSelected)
			dropdownClass="custom-eps-dropdown"
			triggerClass="custom-eps-trigger"
			loadingMessage="Searching users..."
			search=(perform userSearch)
			allowClear=true 
			onchange=(action "userChanged") 
			as |u|}}
			<div class="ps-ml">
				<div class="ps-ml-bold">
					{{u.firstname}} {{u.lastname}}
				</div>
				<div class="ps-ml-reg">
					{{u.username}}
				</div>								
			</div>
		{{/power-select}}

If I take out the selectedItemComponent, it shows the selected object just like it showed in the list, and it has the "x" at the bottom of all the lines on the right.

matthellstrom avatar Apr 10 '17 22:04 matthellstrom

Have you inspected the DOM verify that it's not actually there and this is a CSS/z-index issue? I don't see any reason why it wouldn't be there.

cibernox avatar Apr 10 '17 23:04 cibernox

Yes, it's in the dom, it's on the line below the trigger. I've included a couple of screen shots to show. I'm guessing I have some css that's messing it up, but I don't see anything. screen shot 2017-04-10 at 4 18 25 pm 3 screen shot 2017-04-10 at 4 11 22 pm

matthellstrom avatar Apr 10 '17 23:04 matthellstrom

If I add the code:

top: 0; to ember-power-select-clear-btn class, it works.

matthellstrom avatar Apr 11 '17 16:04 matthellstrom

I think that if your remove the <div> in the template of the selectedItemComponent it should work. It is probably failing because the div is display block and is pushing the x down.

cibernox avatar Apr 18 '17 23:04 cibernox

I tried making the <div> inline-block and removing it altogether. I still have the same issue. The ember-power-select-status-icon is in the right place, the main difference I can see is the top: 0 and bottom: 0 absolute positioning.

matthellstrom avatar Apr 19 '17 15:04 matthellstrom

I need to check if I can make the default styles smarter so this works by default.

cibernox avatar Apr 19 '17 15:04 cibernox

When I added top:0 and bottom:0 to that class it worked fine. But I'm not a whiz at css by any means so it may end up affecting something else.

matthellstrom avatar Apr 19 '17 16:04 matthellstrom

By the way, I LOVE power select, use it all over and more and more of the options all the time. It's fantastic!

matthellstrom avatar Apr 19 '17 16:04 matthellstrom