Skip to content

Commit 8a982be

Browse files
authored
UX: Automatically convert to lowercase in explorer-schema (#325)
* UX: Automatically convert to lowercase in explorer-schema In the past, ExplorerSchema searches were case-sensitive, so if the user's input method capitalized the first letter, it was likely that no results would be found. The new change allows you to enter uppercase letters, which will automatically be converted to lowercase when searching. meta topic: https://meta.discourse.org/t/can-the-data-explorer-search-input-be-converted-to-lower-case/323435
1 parent 978431d commit 8a982be

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

assets/javascripts/discourse/components/explorer-schema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default class ExplorerSchema extends Component {
114114

115115
@debounce(500)
116116
updateFilter(value) {
117-
this.filter = value;
117+
this.filter = value.toLowerCase();
118118
this.loading = false;
119119
}
120120

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { fillIn, render } from "@ember/test-helpers";
2+
import hbs from "htmlbars-inline-precompile";
3+
import { module, test } from "qunit";
4+
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
5+
6+
const schema = {
7+
posts: [
8+
{
9+
column_name: "id",
10+
data_type: "serial",
11+
primary: true,
12+
notes: "primary key",
13+
havetypeinfo: true,
14+
},
15+
{
16+
column_name: "raw",
17+
data_type: "text",
18+
column_desc: "The raw Markdown that the user entered into the composer.",
19+
havepopup: true,
20+
havetypeinfo: true,
21+
},
22+
],
23+
categories: [
24+
{
25+
column_name: "id",
26+
data_type: "serial",
27+
primary: true,
28+
notes: "primary key",
29+
havetypeinfo: true,
30+
},
31+
{
32+
column_name: "name",
33+
data_type: "varchar(50)",
34+
havetypeinfo: false,
35+
},
36+
],
37+
};
38+
39+
module("Data Explorer Plugin | Component | explorer-schema", function (hooks) {
40+
setupRenderingTest(hooks);
41+
42+
test("will automatically convert to lowercase", async function (assert) {
43+
this.setProperties({
44+
schema,
45+
hideSchema: false,
46+
updateHideSchema: () => {},
47+
});
48+
49+
await render(hbs`
50+
<ExplorerSchema
51+
@schema={{this.schema}}
52+
@hideSchema={{this.hideSchema}}
53+
@updateHideSchema={{this.updateHideSchema}}
54+
/>`);
55+
56+
await fillIn(`.schema-search input`, "Cat");
57+
58+
assert.dom(".schema-table").exists();
59+
60+
await fillIn(`.schema-search input`, "NotExist");
61+
62+
assert.dom(".schema-table").doesNotExist();
63+
});
64+
});

0 commit comments

Comments
 (0)