make suggestion box focus more robust, require more explicit enabling (#7123)
Этот коммит содержится в:
@@ -85,7 +85,12 @@ export default class SuggestionBox extends React.Component {
|
|||||||
/**
|
/**
|
||||||
* The number of characters required to show the suggestion list, defaults to 1
|
* The number of characters required to show the suggestion list, defaults to 1
|
||||||
*/
|
*/
|
||||||
requiredCharacters: PropTypes.number
|
requiredCharacters: PropTypes.number,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, the suggestion box is opened on focus, default to false
|
||||||
|
*/
|
||||||
|
openOnFocus: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -94,7 +99,8 @@ export default class SuggestionBox extends React.Component {
|
|||||||
renderDividers: false,
|
renderDividers: false,
|
||||||
completeOnTab: true,
|
completeOnTab: true,
|
||||||
isRHS: false,
|
isRHS: false,
|
||||||
requiredCharacters: 1
|
requiredCharacters: 1,
|
||||||
|
openOnFocus: false
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -145,7 +151,7 @@ export default class SuggestionBox extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTextbox() {
|
getTextbox() {
|
||||||
if (this.props.type === 'textarea') {
|
if (this.props.type === 'textarea' && this.refs.textbox) {
|
||||||
const node = this.refs.textbox.getDOMNode();
|
const node = this.refs.textbox.getDOMNode();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@@ -171,13 +177,17 @@ export default class SuggestionBox extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleFocus() {
|
handleFocus() {
|
||||||
|
if (!this.props.openOnFocus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const textbox = this.getTextbox();
|
const textbox = this.getTextbox();
|
||||||
|
if (textbox) {
|
||||||
const pretext = textbox.value.substring(0, textbox.selectionEnd);
|
const pretext = textbox.value.substring(0, textbox.selectionEnd);
|
||||||
|
|
||||||
if (pretext.length >= this.props.requiredCharacters) {
|
if (pretext.length >= this.props.requiredCharacters) {
|
||||||
GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext);
|
GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +356,7 @@ export default class SuggestionBox extends React.Component {
|
|||||||
Reflect.deleteProperty(props, 'isRHS');
|
Reflect.deleteProperty(props, 'isRHS');
|
||||||
Reflect.deleteProperty(props, 'popoverMentionKeyClick');
|
Reflect.deleteProperty(props, 'popoverMentionKeyClick');
|
||||||
Reflect.deleteProperty(props, 'requiredCharacters');
|
Reflect.deleteProperty(props, 'requiredCharacters');
|
||||||
|
Reflect.deleteProperty(props, 'openOnFocus');
|
||||||
|
|
||||||
const childProps = {
|
const childProps = {
|
||||||
ref: 'textbox',
|
ref: 'textbox',
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ export default class JIRASettings extends AdminSettings {
|
|||||||
disabled={!this.state.enabled}
|
disabled={!this.state.enabled}
|
||||||
type='input'
|
type='input'
|
||||||
requiredCharacters={0}
|
requiredCharacters={0}
|
||||||
|
openOnFocus={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user