Skip to content

Commit a98f513

Browse files
committed
feat: update mentions
1 parent 16e0755 commit a98f513

File tree

7 files changed

+23
-16
lines changed

7 files changed

+23
-16
lines changed

build/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
dev: {
3-
componentName: 'upload', // dev components
3+
componentName: 'mentions', // dev components
44
},
55
};

components/input/Input.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ export default {
192192
keydown: this.handleKeyDown,
193193
change: noop,
194194
},
195-
directives: [
196-
{
197-
name: 'ant-input',
198-
},
199-
],
200195
};
201196
return <TextArea {...textareaProps} ref="input" />;
202197
}

components/input/ResizableTextArea.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ const ResizableTextArea = {
9797
style,
9898
class: cls,
9999
on: omit(getListeners(this), 'pressEnter'),
100+
directives: [
101+
{
102+
name: 'ant-input',
103+
},
104+
],
100105
};
101106
return (
102107
<ResizeObserver onResize={this.resizeOnNextFrame} disabled={!(autoSize || autosize)}>

components/mentions/__test__/__snapshots__/demo.test.js.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ exports[`renders ./components/mentions/demo/basic.md correctly 1`] = `<div class
77
exports[`renders ./components/mentions/demo/form.md correctly 1`] = `
88
<form class="ant-form ant-form-horizontal">
99
<div class="ant-row ant-form-item">
10-
<div class="ant-col-5 ant-form-item-label"><label for="mentions_coders" title="Top coders" class="">Top coders</label></div>
11-
<div class="ant-col-12 ant-form-item-control-wrapper">
10+
<div class="ant-col ant-col-5 ant-form-item-label"><label for="mentions_coders" title="Top coders" class="">Top coders</label></div>
11+
<div class="ant-col ant-col-12 ant-form-item-control-wrapper">
1212
<div class="ant-form-item-control"><span class="ant-form-item-children"><div class="ant-mentions"><textarea rows="1" data-__meta="[object Object]" data-__field="[object Object]" id="mentions_coders"></textarea></div></span>
1313
<!---->
1414
</div>
1515
</div>
1616
</div>
1717
<div class="ant-row ant-form-item">
18-
<div class="ant-col-5 ant-form-item-label"><label for="mentions_bio" title="Bio" class="ant-form-item-required">Bio</label></div>
19-
<div class="ant-col-12 ant-form-item-control-wrapper">
18+
<div class="ant-col ant-col-5 ant-form-item-label"><label for="mentions_bio" title="Bio" class="ant-form-item-required">Bio</label></div>
19+
<div class="ant-col ant-col-12 ant-form-item-control-wrapper">
2020
<div class="ant-form-item-control"><span class="ant-form-item-children"><div class="ant-mentions"><textarea rows="3" placeholder="You can use @ to ref user here" data-__meta="[object Object]" data-__field="[object Object]" id="mentions_bio"></textarea></div></span>
2121
<!---->
2222
</div>
2323
</div>
2424
</div>
2525
<div class="ant-row ant-form-item">
26-
<div class="ant-col-12 ant-col-offset-5 ant-form-item-control-wrapper">
26+
<div class="ant-col ant-col-12 ant-col-offset-5 ant-form-item-control-wrapper">
2727
<div class="ant-form-item-control"><span class="ant-form-item-children"><button type="button" class="ant-btn ant-btn-primary"><span>Submit</span></button><button type="button" class="ant-btn" style="margin-left: 8px;"><span>Reset</span></button></span>
2828
<!---->
2929
</div>

components/mentions/demo/basic.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Basic usage.
1111
```tpl
1212
<template>
1313
<a-mentions
14-
defaultValue="@afc163"
14+
v-model="value"
1515
@change="onChange"
1616
@select="onSelect"
1717
>
@@ -22,6 +22,11 @@ Basic usage.
2222
</template>
2323
<script>
2424
export default {
25+
data() {
26+
return {
27+
value: '@afc163',
28+
}
29+
},
2530
methods: {
2631
onSelect(option) {
2732
console.log('select', option);

components/vc-mentions/src/DropdownMenu.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Menu, { MenuItem } from '../../vc-menu';
22
import PropTypes from '../../_util/vue-types';
33
import { OptionProps } from './Option';
44

5+
function noop() {}
56
export default {
67
name: 'DropdownMenu',
78
props: {
@@ -18,8 +19,8 @@ export default {
1819
activeIndex,
1920
setActiveIndex,
2021
selectOption,
21-
onFocus,
22-
onBlur,
22+
onFocus = noop,
23+
onBlur = noop,
2324
} = this.mentionsContext;
2425
const { prefixCls, options } = this.$props;
2526
const activeOption = options[activeIndex] || {};

components/vc-mentions/src/Mentions.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import omit from 'omit.js';
22
import KeyCode from '../../_util/KeyCode';
33
import BaseMixin from '../../_util/BaseMixin';
44
import {
5-
getStyle,
65
getSlots,
76
hasProp,
87
getOptionProps,
@@ -73,7 +72,8 @@ const Mentions = {
7372
}
7473
this.$emit('change', value);
7574
},
76-
onChange({ target: { value } }) {
75+
onChange({ target: { value, composing } }) {
76+
if (composing) return;
7777
this.triggerChange(value);
7878
},
7979
onKeyDown(event) {
@@ -283,6 +283,7 @@ const Mentions = {
283283
<textarea
284284
ref="textarea"
285285
{...{
286+
directives: [{ name: 'ant-input' }],
286287
attrs: { ...inputProps, ...this.$attrs },
287288
domProps: {
288289
value,

0 commit comments

Comments
 (0)