Skip to content

Commit

Permalink
Fix search nodes panel (do not catch ctrl f) (#6322) (#6358)
Browse files Browse the repository at this point in the history
* Fix search nodes panel (do not catch ctrl f) (#6322)
  • Loading branch information
gskrobisz authored Jul 10, 2024
1 parent cc23f79 commit f8a1b3c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 50 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 3 additions & 11 deletions designer/client/cypress/e2e/process2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ describe("Process view", () => {

it("should have node search toolbar", () => {
cy.get("[data-testid=search-panel]").should("be.visible");
cy.get("[data-testid=search-panel]")
.contains(/^search$/i)
.click();
cy.get("[title='toggle left panel']").click();
cy.get("[data-testid=search-panel]").should("be.not.visible");
cy.get("#nk-graph-main").click();
cy.realPress(["Meta", "F"]);
cy.get("[data-testid=search-panel] input").should("be.visible").should("be.focused");
cy.get("[data-testid=search-panel]").contains(/^search$/i);
cy.get("[data-testid=search-panel] input").click();
cy.realType("en");
cy.get("[data-testid=search-panel]").contains(/sms/i).click();
cy.getNode("enricher")
Expand All @@ -46,9 +40,7 @@ describe("Process view", () => {
cy.get("[data-testid=window]")
.contains(/^cancel$/i)
.click();
cy.get("#nk-graph-main").click();
cy.realPress(["Meta", "F"]);
cy.get("[data-testid=search-panel] input").should("be.visible").should("be.focused");
cy.get("[data-testid=search-panel] input").click().clear();
cy.realType("source");
cy.wait(750); //wait for animation
cy.getNode("enricher")
Expand Down
39 changes: 1 addition & 38 deletions designer/client/src/components/toolbars/search/SearchPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { isEmpty } from "lodash";
import React, { ReactElement, useCallback, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { toggleToolbar } from "../../../actions/nk/toolbars";
import { useDocumentListeners } from "../../../containers/useDocumentListeners";
import { getToolbarsConfigId } from "../../../reducers/selectors/toolbars";
import { useSidePanel } from "../../sidePanels/SidePanel";
import { SearchIcon } from "../../table/SearchFilter";
import { Focusable } from "../../themed/InputWithIcon";
import { ToolbarPanelProps } from "../../toolbarComponents/DefaultToolbarPanel";
Expand All @@ -15,42 +10,10 @@ import { SearchInputWithIcon } from "../../themed/SearchInput";

export function SearchPanel(props: ToolbarPanelProps): ReactElement {
const { t } = useTranslation();
const dispatch = useDispatch();
const toolbarsConfigId = useSelector(getToolbarsConfigId);

const [filter, setFilter] = useState<string>("");
const clearFilter = useCallback(() => setFilter(""), []);

const searchRef = useRef<Focusable>();
const sidePanel = useSidePanel();

useDocumentListeners({
keydown: (e) => {
switch (e.key.toUpperCase()) {
case "ESCAPE": {
e.preventDefault();
e.stopImmediatePropagation();
clearFilter();
const target = e.composedPath().shift();
if (target instanceof HTMLElement) {
target.blur();
}
break;
}
case "F": {
if (!e.ctrlKey && !e.metaKey) return;
e.preventDefault();
e.stopPropagation();
if (!sidePanel.isOpened) {
sidePanel.onToggle();
}
dispatch(toggleToolbar(props.id, toolbarsConfigId, false));
searchRef.current.focus();
break;
}
}
},
});

return (
<ToolbarWrapper {...props} title={t("panels.search.title", "Search")} onExpand={() => searchRef.current?.focus()}>
Expand All @@ -63,7 +26,7 @@ export function SearchPanel(props: ToolbarPanelProps): ReactElement {
>
<SearchIcon isEmpty={isEmpty(filter)} />
</SearchInputWithIcon>
<SearchResults filterValues={filter.toLowerCase().split(/\s/).filter(Boolean)} />
<SearchResults filterValues={[filter.toLowerCase()].filter(Boolean)} />
</ToolbarWrapper>
);
}
3 changes: 2 additions & 1 deletion docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

1.15.4 (5 July 2025)
1.15.4 (10 July 2025)
-------------------------
* [#6319](https://github.com/TouK/nussknacker/pull/6319) Fix migration between environments.
* [#6322](https://github.com/TouK/nussknacker/pull/6322) Fix search nodes: usage of ctrl-f was limited to nodes search only.

1.15.3 (24 June 2024)
-------------------------
Expand Down

0 comments on commit f8a1b3c

Please sign in to comment.