mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
web: can't add a tag that's a substring of another tag (fixes #1002)
This commit is contained in:
@@ -17,5 +17,26 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { test } from "@playwright/test";
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { AppModel } from "./models/app.model";
|
||||
import { NOTE } from "./utils";
|
||||
test.skip("TODO: make sure jump to group works", () => {});
|
||||
|
||||
test("#1002 Can't add a tag that's a substring of an existing tag", async ({
|
||||
page
|
||||
}) => {
|
||||
const tags = ["chromeos-105", "chromeos"];
|
||||
const app = new AppModel(page);
|
||||
await app.goto();
|
||||
const tagsView = await app.goToTags();
|
||||
await tagsView.createItem({ title: "chromeos-105" });
|
||||
const notes = await app.goToNotes();
|
||||
await notes.createNote(NOTE);
|
||||
|
||||
await notes.editor.setTags(tags);
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
const noteTags = await notes.editor.getTags();
|
||||
expect(noteTags).toHaveLength(tags.length);
|
||||
expect(noteTags.every((t, i) => t === tags[i])).toBe(true);
|
||||
});
|
||||
|
||||
@@ -110,14 +110,21 @@ function Autosuggest({
|
||||
if (filterText.length <= 0 && filtered.length <= 0) {
|
||||
closeMenu();
|
||||
return;
|
||||
} else if (filterText.length > 0 && filtered.length <= 0) {
|
||||
}
|
||||
|
||||
if (
|
||||
filterText.length > 0 &&
|
||||
filtered.every((item) => item.title !== filterText)
|
||||
) {
|
||||
items.push({
|
||||
key: "new",
|
||||
title: () => `Create "${filterText}" tag`,
|
||||
icon: Icon.Plus,
|
||||
onClick: () => onAction("add", filterText)
|
||||
});
|
||||
} else {
|
||||
}
|
||||
|
||||
if (filtered.length > 0) {
|
||||
items.push(
|
||||
...filtered.map((tag) => ({
|
||||
key: tag.id,
|
||||
@@ -177,6 +184,8 @@ function Autosuggest({
|
||||
const text = getInputValue();
|
||||
if (e.key === "Enter" && !!text && !filtered.length) {
|
||||
onAction("add", text);
|
||||
} else if (e.key === "Enter" && !!text && !!filtered.length) {
|
||||
onAction("select", filtered[0]);
|
||||
} else if (!text && e.key === "Backspace") {
|
||||
onRemove();
|
||||
setFiltered([]);
|
||||
|
||||
Reference in New Issue
Block a user