Refactor #3965 - Refactor on Dropdown

pull/4077/head
Tuğçe Küçükoğlu 2023-06-22 16:29:47 +03:00
parent ff403897d2
commit af5a0b090d
2 changed files with 4 additions and 4 deletions

View File

@ -98,13 +98,13 @@ input.p-dropdown-label {
`; `;
const classes = { const classes = {
root: ({ props, state }) => [ root: ({ instance, props, state }) => [
'p-dropdown p-component p-inputwrapper', 'p-dropdown p-component p-inputwrapper',
{ {
'p-disabled': props.disabled, 'p-disabled': props.disabled,
'p-dropdown-clearable': props.showClear && !props.disabled, 'p-dropdown-clearable': props.showClear && !props.disabled,
'p-focus': state.focused, 'p-focus': state.focused,
'p-inputwrapper-filled': props.hasSelectedOption, 'p-inputwrapper-filled': instance.hasSelectedOption,
'p-inputwrapper-focus': state.focused || state.overlayVisible, 'p-inputwrapper-focus': state.focused || state.overlayVisible,
'p-overlay-open': state.overlayVisible 'p-overlay-open': state.overlayVisible
} }

View File

@ -48,7 +48,7 @@
<slot name="value" :value="modelValue" :placeholder="placeholder">{{ label === 'p-emptylabel' ? '&nbsp;' : label || 'empty' }}</slot> <slot name="value" :value="modelValue" :placeholder="placeholder">{{ label === 'p-emptylabel' ? '&nbsp;' : label || 'empty' }}</slot>
</span> </span>
<slot v-if="showClear && modelValue != null" name="clearicon" :class="cx('clearIcon')" :onClick="onClearClick"> <slot v-if="showClear && modelValue != null" name="clearicon" :class="cx('clearIcon')" :onClick="onClearClick">
<component :is="clearIcon ? 'i' : 'TimesIcon'" ref="clearIcon" :class="[cx('clearIcon'), clearIcon]" @click="onClearClick" v-bind="{ ...clearIconProps, ...ptm('clearIcon') }" /> <component :is="clearIcon ? 'i' : 'TimesIcon'" ref="clearIcon" :class="[cx('clearIcon'), clearIcon]" @click="onClearClick" v-bind="{ ...clearIconProps, ...ptm('clearIcon') }" data-pc-section="clearicon" />
</slot> </slot>
<div :class="cx('trigger')" v-bind="ptm('trigger')"> <div :class="cx('trigger')" v-bind="ptm('trigger')">
<slot v-if="loading" name="loadingicon" :class="cx('loadingIcon')"> <slot v-if="loading" name="loadingicon" :class="cx('loadingIcon')">
@ -422,7 +422,7 @@ export default {
return; return;
} }
if ((this.$refs.clearIcon && this.$refs.clearIcon.isSameNode(event.target)) || event.target.tagName === 'INPUT') { if (event.target.tagName === 'INPUT' || event.target.getAttribute('data-pc-section') === 'clearicon' || event.target.tagName === 'path') {
return; return;
} else if (!this.overlay || !this.overlay.contains(event.target)) { } else if (!this.overlay || !this.overlay.contains(event.target)) {
this.overlayVisible ? this.hide(true) : this.show(true); this.overlayVisible ? this.hide(true) : this.show(true);