bootstrap_typeahead: Remove fixed argument.

Tippy uses a different strategy for positioning items, so this
will not be required.
This commit is contained in:
Aman Agrawal
2024-04-24 09:15:05 +00:00
committed by Tim Abbott
parent 12984c9cef
commit 689489573a
6 changed files with 1 additions and 20 deletions

View File

@@ -209,7 +209,6 @@ export class Typeahead<ItemType extends string | object> {
$header: JQuery; $header: JQuery;
source: (query: string, input_element: TypeaheadInputElement) => ItemType[]; source: (query: string, input_element: TypeaheadInputElement) => ItemType[];
dropup: boolean; dropup: boolean;
fixed: boolean;
automated: () => boolean; automated: () => boolean;
trigger_selection: (event: JQuery.KeyDownEvent) => boolean; trigger_selection: (event: JQuery.KeyDownEvent) => boolean;
on_escape?: () => void; on_escape?: () => void;
@@ -248,7 +247,6 @@ export class Typeahead<ItemType extends string | object> {
this.$header = $(HEADER_ELEMENT_HTML).appendTo(this.$container); this.$header = $(HEADER_ELEMENT_HTML).appendTo(this.$container);
this.source = options.source; this.source = options.source;
this.dropup = options.dropup ?? false; this.dropup = options.dropup ?? false;
this.fixed = options.fixed ?? false;
this.automated = options.automated ?? (() => false); this.automated = options.automated ?? (() => false);
this.trigger_selection = options.trigger_selection ?? (() => false); this.trigger_selection = options.trigger_selection ?? (() => false);
this.on_escape = options.on_escape; this.on_escape = options.on_escape;
@@ -266,9 +264,6 @@ export class Typeahead<ItemType extends string | object> {
this.parentElement = options.parentElement; this.parentElement = options.parentElement;
this.values = new WeakMap(); this.values = new WeakMap();
if (this.fixed) {
this.$container.css("position", "fixed");
}
// The naturalSearch option causes arrow keys to immediately // The naturalSearch option causes arrow keys to immediately
// update the search box with the underlying values from the // update the search box with the underlying values from the
// search suggestions. // search suggestions.
@@ -329,12 +324,7 @@ export class Typeahead<ItemType extends string | object> {
if (this.parentElement === undefined) { if (this.parentElement === undefined) {
let pos; let pos;
if (this.fixed) { pos = this.input_element.$element[0].getBoundingClientRect();
// Relative to screen instead of to page
pos = this.input_element.$element[0].getBoundingClientRect();
} else {
pos = this.input_element.$element.offset();
}
pos = $.extend({}, pos, { pos = $.extend({}, pos, {
height: this.input_element.$element[0].offsetHeight, height: this.input_element.$element[0].offsetHeight,
@@ -709,7 +699,6 @@ type TypeaheadOptions<ItemType> = {
automated?: () => boolean; automated?: () => boolean;
closeInputFieldOnHide?: () => void; closeInputFieldOnHide?: () => void;
dropup?: boolean; dropup?: boolean;
fixed?: boolean;
header_html?: () => string | false; header_html?: () => string | false;
helpOnEmptyStrings?: boolean; helpOnEmptyStrings?: boolean;
matcher?: (item: ItemType, query: string) => boolean; matcher?: (item: ItemType, query: string) => boolean;

View File

@@ -1109,7 +1109,6 @@ export function initialize_topic_edit_typeahead(form_field, stream_name, dropup)
type: "input", type: "input",
}; };
return new Typeahead(bootstrap_typeahead_input, { return new Typeahead(bootstrap_typeahead_input, {
fixed: true,
dropup, dropup,
highlighter_html(item) { highlighter_html(item) {
return typeahead_helper.render_typeahead_item({primary: item}); return typeahead_helper.render_typeahead_item({primary: item});
@@ -1161,7 +1160,6 @@ export function initialize_compose_typeahead(selector) {
new Typeahead(bootstrap_typeahead_input, { new Typeahead(bootstrap_typeahead_input, {
items: max_num_items, items: max_num_items,
dropup: true, dropup: true,
fixed: true,
// Performance note: We have trivial matcher/sorters to do // Performance note: We have trivial matcher/sorters to do
// matching and sorting inside the `source` field to avoid // matching and sorting inside the `source` field to avoid
// O(n) behavior in the number of users in the organization // O(n) behavior in the number of users in the organization
@@ -1196,7 +1194,6 @@ export function initialize({on_enter_send}) {
return topics_seen_for(compose_state.stream_id()); return topics_seen_for(compose_state.stream_id());
}, },
items: 3, items: 3,
fixed: true,
highlighter_html(item) { highlighter_html(item) {
return typeahead_helper.render_typeahead_item({primary: item}); return typeahead_helper.render_typeahead_item({primary: item});
}, },
@@ -1224,7 +1221,6 @@ export function initialize({on_enter_send}) {
source: get_pm_people, source: get_pm_people,
items: max_num_items, items: max_num_items,
dropup: true, dropup: true,
fixed: true,
highlighter_html(item) { highlighter_html(item) {
return typeahead_helper.render_person_or_user_group(item); return typeahead_helper.render_person_or_user_group(item);
}, },

View File

@@ -172,7 +172,6 @@ export function initialize_custom_pronouns_type_fields(element_id) {
}; };
new Typeahead(bootstrap_typeahead_input, { new Typeahead(bootstrap_typeahead_input, {
items: 3, items: 3,
fixed: true,
helpOnEmptyStrings: true, helpOnEmptyStrings: true,
source() { source() {
return commonly_used_pronouns; return commonly_used_pronouns;

View File

@@ -55,7 +55,6 @@ export function set_up(
}; };
new Typeahead(bootstrap_typeahead_input, { new Typeahead(bootstrap_typeahead_input, {
items: 5, items: 5,
fixed: true,
dropup: true, dropup: true,
source(query: string): TypeaheadItem[] { source(query: string): TypeaheadItem[] {
let source: TypeaheadItem[] = []; let source: TypeaheadItem[] = [];

View File

@@ -170,7 +170,6 @@ function build_page(): void {
return [...language_labels.keys()]; return [...language_labels.keys()];
}, },
items: 5, items: 5,
fixed: true,
helpOnEmptyStrings: true, helpOnEmptyStrings: true,
highlighter_html: (item: string): string => highlighter_html: (item: string): string =>
render_typeahead_item({primary: language_labels.get(item)}), render_typeahead_item({primary: language_labels.get(item)}),

View File

@@ -162,7 +162,6 @@ run_test("set_up", ({mock_template, override, override_rewire}) => {
override(bootstrap_typeahead, "Typeahead", (input_element, config) => { override(bootstrap_typeahead, "Typeahead", (input_element, config) => {
assert.equal(input_element.$element, $fake_input); assert.equal(input_element.$element, $fake_input);
assert.equal(config.items, 5); assert.equal(config.items, 5);
assert.ok(config.fixed);
assert.ok(config.dropup); assert.ok(config.dropup);
assert.ok(config.stopAdvance); assert.ok(config.stopAdvance);