Przeglądaj źródła

Bugfix. String needs to be set as component property, not function

JC Brand 3 miesięcy temu
rodzic
commit
7e6309c0cf

+ 1 - 1
src/plugins/muc-views/modals/templates/muc-invite.js

@@ -13,7 +13,7 @@ export default (el) => {
                 <label class="form-label clearfix" for="invitee_jids">${i18n_invite_label}:</label>
                 ${ el.model.get('invalid_invite_jid') ? html`<div class="error error-feedback">${i18n_error_message}</div>` : '' }
                 <converse-autocomplete
-                    .getAutoCompleteList=${() => el.getAutoCompleteList()}
+                    .getAutoCompleteList="${() => el.getAutoCompleteList()}"
                     ?autofocus=${true}
                     min_chars="1"
                     position="below"

+ 3 - 4
src/plugins/rosterview/modals/templates/add-contact.js

@@ -3,7 +3,6 @@ import { api } from "@converse/headless";
 import { __ } from "i18n";
 import { getGroupsAutoCompleteList, getJIDsAutoCompleteList, getNamesAutoCompleteList } from "../../utils.js";
 import "shared/autocomplete/index.js";
-import { FILTER_STARTSWITH, FILTER_CONTAINS } from "shared/autocomplete/utils.js";
 
 /**
  * @param {import('../add-contact.js').default} el
@@ -28,8 +27,8 @@ export default (el) => {
                           .getAutoCompleteList=${getNamesAutoCompleteList}
                           position="below"
                           min_chars="2"
-                          filter="${FILTER_CONTAINS}"
-                          ?required=${true}
+                          filter="contains"
+                          ?required="${true}"
                           value="${el.model.get("jid") || ""}"
                           placeholder="${i18n_contact_placeholder}"
                           name="jid"
@@ -39,7 +38,7 @@ export default (el) => {
                           .data="${(text, input) => `${input.slice(0, input.indexOf("@"))}@${text}`}"
                           position="below"
                           min_chars="2"
-                          filter="${FILTER_STARTSWITH}"
+                          filter="startswith"
                           ?required="${!api.settings.get("xhr_user_search_url")}"
                           value="${el.model.get("jid") || ""}"
                           placeholder="${i18n_contact_placeholder}"

+ 6 - 1
src/shared/autocomplete/utils.js

@@ -61,7 +61,12 @@ export function FILTER_STARTSWITH (text, input) {
     return RegExp('^' + helpers.regExpEscape(input.trim()), 'i').test(text);
 };
 
-const SORT_BY_LENGTH = function (a, b) {
+/**
+ * @param {string} a
+ * @param {string} b
+ * @returns {number}
+ */
+export function SORT_BY_LENGTH (a, b) {
     if (a.length !== b.length) {
         return a.length - b.length;
     }

+ 6 - 0
src/types/shared/autocomplete/utils.d.ts

@@ -10,6 +10,12 @@ export function FILTER_CONTAINS(text: string, input: string): boolean;
  * @returns {boolean}
  */
 export function FILTER_STARTSWITH(text: string, input: string): boolean;
+/**
+ * @param {string} a
+ * @param {string} b
+ * @returns {number}
+ */
+export function SORT_BY_LENGTH(a: string, b: string): number;
 export namespace helpers {
     function getElement(expr: any, el: any): any;
     function bind(element: any, o: any): void;