Commit b2553a44 authored by JC Brand's avatar JC Brand

New configuration setting: `auto_focus`

parent 536b4269
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
- Message deduplication bugfixes and improvements - Message deduplication bugfixes and improvements
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure - Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs). - Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus).
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks). - New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks).
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status) - New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit) - New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit)
......
...@@ -231,6 +231,20 @@ autocomplete_add_contact ...@@ -231,6 +231,20 @@ autocomplete_add_contact
Determines whether search suggestions are shown in the "Add Contact" modal. Determines whether search suggestions are shown in the "Add Contact" modal.
auto_focus
----------
* Default: ``true``
If set to ``true``, the textarea for composing chat messages will automatically
become focused as soon as a chat is opened. This means you don't need to click
the textarea first before starting to type a message.
For applications where chat is not the main feature, automatic focus of the
chat box might be undesired.
auto_list_rooms auto_list_rooms
--------------- ---------------
......
...@@ -56,6 +56,7 @@ converse.plugins.add('converse-chatview', { ...@@ -56,6 +56,7 @@ converse.plugins.add('converse-chatview', {
{ __ } = _converse; { __ } = _converse;
_converse.api.settings.update({ _converse.api.settings.update({
'auto_focus': true,
'emoji_image_path': twemoji.default.base, 'emoji_image_path': twemoji.default.base,
'message_limit': 0, 'message_limit': 0,
'show_send_button': false, 'show_send_button': false,
...@@ -1290,13 +1291,17 @@ converse.plugins.add('converse-chatview', { ...@@ -1290,13 +1291,17 @@ converse.plugins.add('converse-chatview', {
this.model.clearUnreadMsgCounter(); this.model.clearUnreadMsgCounter();
this.setChatState(_converse.ACTIVE); this.setChatState(_converse.ACTIVE);
this.scrollDown(); this.scrollDown();
this.focus(); if (_converse.auto_focus) {
this.focus();
}
}, },
_show () { _show () {
/* Inner show method that gets debounced */ /* Inner show method that gets debounced */
if (u.isVisible(this.el)) { if (u.isVisible(this.el)) {
this.focus(); if (_converse.auto_focus) {
this.focus();
}
return; return;
} }
u.fadeIn(this.el, _.bind(this.afterShown, this)); u.fadeIn(this.el, _.bind(this.afterShown, this));
......
...@@ -684,7 +684,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -684,7 +684,9 @@ converse.plugins.add('converse-muc-views', {
show () { show () {
if (u.isVisible(this.el)) { if (u.isVisible(this.el)) {
this.focus(); if (_converse.auto_focus) {
this.focus();
}
return; return;
} }
// Override from converse-chatview in order to not use // Override from converse-chatview in order to not use
...@@ -704,7 +706,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -704,7 +706,9 @@ converse.plugins.add('converse-muc-views', {
} else if (conn_status === converse.ROOMSTATUS.ENTERED) { } else if (conn_status === converse.ROOMSTATUS.ENTERED) {
this.hideSpinner(); this.hideSpinner();
this.setChatState(_converse.ACTIVE); this.setChatState(_converse.ACTIVE);
this.focus(); if (_converse.auto_focus) {
this.focus();
}
} else if (conn_status === converse.ROOMSTATUS.DISCONNECTED) { } else if (conn_status === converse.ROOMSTATUS.DISCONNECTED) {
this.showDisconnectMessage(); this.showDisconnectMessage();
} else if (conn_status === converse.ROOMSTATUS.DESTROYED) { } else if (conn_status === converse.ROOMSTATUS.DESTROYED) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment