)
@@ -77,9 +83,17 @@
if (!this.shouldShowArrow) return null
+ const arrowIconRenderer = instance.$scopedSlots['arrow-icon']
return (
-
-
+
+ {arrowIconRenderer ? (
+ arrowIconRenderer({ isOpen: instance.menu.isOpen })
+ ) : (
+
+ )}
)
},
@@ -129,11 +143,7 @@
// This is meant to be called by child `
` component.
renderValueContainer(children) {
- return (
-
- {children}
-
- )
+ return
{children}
},
},
@@ -142,7 +152,10 @@
const ValueContainer = instance.single ? SingleValue : MultiValue
return (
-
+
{this.renderX()}
{this.renderArrow()}
diff --git a/test/unit/specs/Control.spec.js b/test/unit/specs/Control.spec.js
index 14825585..f324b638 100644
--- a/test/unit/specs/Control.spec.js
+++ b/test/unit/specs/Control.spec.js
@@ -18,4 +18,35 @@ describe('Control', () => {
leftClick(arrow)
expect(wrapper.vm.menu.isOpen).toBe(false)
})
+
+ it('should render custom slot if provided', () => {
+ const openLabel = 'O'
+ const closeLabel = 'C'
+ const template = `
+
+
+ {{ isOpen ? "${openLabel}" : "${closeLabel}" }}
+
+
+ `
+
+ const wrapper = mount({
+ template,
+ components: { Treeselect },
+ data() {
+ return {
+ options: [],
+ value: '',
+ }
+ },
+ })
+
+ const treeselect = wrapper.vm.$refs.treeselect
+ expect(treeselect.menu.isOpen).toBe(false)
+ const arrowLabel = wrapper.find('.vue-treeselect__control-arrow-container')
+ expect(arrowLabel.text()).toBe(closeLabel)
+ leftClick(arrowLabel)
+ expect(treeselect.menu.isOpen).toBe(true)
+ expect(arrowLabel.text()).toBe(openLabel)
+ })
})