Skip to content
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
4 changes: 2 additions & 2 deletions packages/ringcentral-widgets-test/test/dialer/Dialer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ beforeEach(async () => {
});

const clickButton = (button) => {
button.find('g').first().props().onMouseDown();
button.find('g').first().props().onMouseUp();
button.find('g').first().simulate('mouseDown');
button.find('g').first().simulate('mouseUp');
wrapper.update();
};

Expand Down
3 changes: 2 additions & 1 deletion packages/ringcentral-widgets/components/DialButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class DialButton extends Component {
this.audio = document.createElement('audio');
this.audio.src = audios[props.btn.value];
}
this.onMouseDown = () => {
this.onMouseDown = (e) => {
if (this.audio && this.audio.canPlayType('audio/ogg') !== '') {
this.audio.volume = this.props.volume;
this.audio.muted = this.props.muted;
Expand Down Expand Up @@ -52,6 +52,7 @@ export default class DialButton extends Component {
this.setState({
pressed: true,
});
e.preventDefault();
};
this.onMouseUp = () => {
if (this.state.pressed) {
Expand Down
32 changes: 29 additions & 3 deletions packages/ringcentral-widgets/components/RecipientsInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ import RemoveButton from '../RemoveButton';
import ContactDropdownList from '../ContactDropdownList';
import i18n from './i18n';

/**
* Set mouse focus and move cursor to end of input
* @param {HTMLElement} inputField
*/
const focusCampo = (inputField) => {
inputField.blur();
if (inputField && inputField.value.length !== 0) {
if (inputField.createTextRange) {
const FieldRange = inputField.createTextRange();
FieldRange.moveStart('character', inputField.value.length);
FieldRange.collapse();
FieldRange.select();
} else if (inputField.selectionStart || inputField.selectionStart === 0) {
const elemLen = inputField.value.length;
inputField.selectionStart = elemLen;
inputField.selectionEnd = elemLen;
}
}
inputField.focus();
};

function SelectedRecipientItem({
phoneNumber,
name = phoneNumber,
Expand Down Expand Up @@ -208,8 +229,9 @@ class RecipientsInput extends Component {

onInputChange = (e) => {
const { value } = e.currentTarget;
this.setState({ value });
this.props.onChange(value);
this.setState({ value }, () => {
this.props.onChange(value);
});
if (this.listRef) {
this.listRef.scrollTop = 0;
}
Expand All @@ -226,7 +248,11 @@ class RecipientsInput extends Component {
nextProps.value !== this.props.value &&
nextProps.value !== this.state.value
) {
this.setState({ value: nextProps.value });
this.setState({ value: nextProps.value }, () => {
if (this.inputRef) {
focusCampo(this.inputRef);
}
});
this.props.searchContact(nextProps.value);
}
}
Expand Down