Commit b831dd93 authored by dmacfarlane's avatar dmacfarlane
Browse files

Option to disable sorting of suggested items

parent a1c9ff0c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ The following optional configuration items can be used.
| maxItems      |          | Limit the number of items shown in the pop-up menu. The default is no limit. |
| maxItems      |          | Limit the number of items shown in the pop-up menu. The default is no limit. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| labelKey      | label    | The field to be used as the item label (when the items are objects). |
| labelKey      | label    | The field to be used as the item label (when the items are objects). |
| disableSort   | false    | Dsiable sorting of suggested items. |
| disableSearch | false    | Disable internal filtering (only useful if async search is used). |
| disableSearch | false    | Disable internal filtering (only useful if async search is used). |


For Example: 
For Example: 
+3 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,9 @@ export interface Mentions {
  // option to limit the number of items shown in the pop-up menu
  // option to limit the number of items shown in the pop-up menu
  maxItems?:number;
  maxItems?:number;


  // option to disable sorting
  disableSort?:boolean;
  
  // optional function to format the selected item before inserting the text
  // optional function to format the selected item before inserting the text
  mentionSelect?:(item: any) => (string);
  mentionSelect?:(item: any) => (string);
}
}
 No newline at end of file
+3 −1
Original line number Original line Diff line number Diff line
@@ -116,8 +116,10 @@ export class MentionDirective implements OnChanges {
      }
      }
      // remove items without an labelKey (as it's required to filter the list)
      // remove items without an labelKey (as it's required to filter the list)
      items = items.filter(e => e[config.labelKey]);
      items = items.filter(e => e[config.labelKey]);
      if (!config.disableSort) {
        items.sort((a,b)=>a[config.labelKey].localeCompare(b[config.labelKey]));
        items.sort((a,b)=>a[config.labelKey].localeCompare(b[config.labelKey]));
      }
      }
    }
    config.items = items;
    config.items = items;


    // add the config
    // add the config