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

fix select multiple mode #1091

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export default mixins(getConfigReceiverMixins<InputInstance, InputConfig>('input
handler(val) {
if (val === true) {
this.$nextTick(() => {
(this.$refs.inputRef as HTMLInputElement).focus();
const input = this.$refs.inputRef as HTMLInputElement;
input?.focus();
});
}
},
Expand Down Expand Up @@ -290,7 +291,9 @@ export default mixins(getConfigReceiverMixins<InputInstance, InputConfig>('input
const pre = this.$refs.inputPreRef as HTMLSpanElement;
if (!pre) return;
const width = pre.offsetWidth;
(this.$refs.inputRef as HTMLInputElement).style.width = `${width}px`;
if (this.$refs.inputRef) {
(this.$refs.inputRef as HTMLInputElement).style.width = `${width}px`;
}
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/tag-input/tag-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default defineComponent({
onChange={(val: InputValue, context?: { e?: InputEvent | MouseEvent }) => {
this.setTInputValue(val, { ...context, trigger: 'input' });
}}
showInput={!this.inputProps?.readonly}
showInput={!this.inputProps?.readonly || !this.tagValue || !this.tagValue?.length}
keepWrapperWidth={true}
onMousewheel={this.onWheel}
autoWidth={this.autoWidth}
Expand Down
2 changes: 1 addition & 1 deletion test/ssr/__snapshots__/ssr.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11651,7 +11651,7 @@ exports[`ssr snapshot test renders ./examples/select/demos/max.vue correctly 1`]
<div class="t-select__wrap" style="width:200px;">
<div class="t-input__wrap t-tag-input t-tag-input--break-line t-select-input--multiple t-select-input--empty t-select">
<div class="t-input t-size-m t-is-default t-is-readonly t-input--prefix t-input--suffix">
<div class="t-input__prefix"></div><span class="t-input__input-pre">-请选择-</span><span class="t-input__suffix t-input__suffix-icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="t-fake-arrow t-select__right-icon"><path d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921" stroke="black" stroke-opacity="0.9" stroke-width="1.3"></path></svg></span>
<div class="t-input__prefix"></div><input readonly="readonly" autocomplete="" placeholder="-请选择-" type="text" unselectable="on" value="" class="t-input__inner"><span class="t-input__input-pre">-请选择-</span><span class="t-input__suffix t-input__suffix-icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="t-fake-arrow t-select__right-icon"><path d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921" stroke="black" stroke-opacity="0.9" stroke-width="1.3"></path></svg></span>
</div>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions test/unit/select/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,14 @@ exports[`Select Select maxVue demo works fine 1`] = `
<div
class="t-input__prefix"
/>
<input
autocomplete=""
class="t-input__inner"
placeholder="-请选择-"
readonly="readonly"
type="text"
unselectable="on"
/>
<span
class="t-input__input-pre"
>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/select/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports[`Select :props :multiple 1`] = `
<div class="t-select__wrap">
<div class="t-input__wrap t-tag-input t-tag-input--break-line t-select-input--multiple t-select-input--empty t-select">
<div class="t-input t-size-m t-is-default t-is-readonly t-input--prefix t-input--suffix">
<div class="t-input__prefix"></div><span class="t-input__input-pre">请选择</span><span class="t-input__suffix t-input__suffix-icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="t-fake-arrow t-select__right-icon"><path d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921" stroke="black" stroke-opacity="0.9" stroke-width="1.3"></path></svg></span>
<div class="t-input__prefix"></div><input readonly="readonly" autocomplete="" placeholder="请选择" type="text" unselectable="on" class="t-input__inner"><span class="t-input__input-pre">请选择</span><span class="t-input__suffix t-input__suffix-icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="t-fake-arrow t-select__right-icon"><path d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921" stroke="black" stroke-opacity="0.9" stroke-width="1.3"></path></svg></span>
</div>
</div>
</div>
Expand Down