Skip to content

Commit

Permalink
Improve ux with search
Browse files Browse the repository at this point in the history
  • Loading branch information
vraja-nayaka committed Jun 2, 2024
1 parent 874ee8d commit 6548f0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/common/src/components/forms/report/ReportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Button,
List,
Input,
InputRef,
InputNumber,
Form,
Checkbox,
Expand Down Expand Up @@ -56,6 +57,7 @@ export const ReportForm = (props: Props) => {
const { toggleFavorite } = useUser({ profile });
const [searchString, setSearchString] = useState("");
const [showOnliFirstBooks, setShowOnliFirstBooks] = useState(storage.getShowOnliFirstBooks());
const searchRef = useRef<InputRef>(null);

const onShowOnliFirstBooksChange = (flag: boolean) => {
setShowOnliFirstBooks(flag);
Expand Down Expand Up @@ -156,6 +158,7 @@ export const ReportForm = (props: Props) => {

const onPlusClick = useCallback(
(bookId: string) => {
searchRef.current?.focus();
const prevValue = form.getFieldValue(bookId) || 0;
form.setFieldsValue({ [bookId]: prevValue + 1 });
onValuesChange();
Expand All @@ -165,6 +168,7 @@ export const ReportForm = (props: Props) => {

const onMinusClick = useCallback(
(bookId: string) => {
searchRef.current?.focus();
const prevValue = form.getFieldValue(bookId) || 0;
if (prevValue !== 0) {
form.setFieldsValue({ [bookId]: prevValue - 1 });
Expand Down Expand Up @@ -253,6 +257,7 @@ export const ReportForm = (props: Props) => {

<Row>
<Search
ref={searchRef}
placeholder="поиск книги"
allowClear
onChange={debouncedSearch}
Expand Down
2 changes: 1 addition & 1 deletion packages/tracker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tracker",
"version": "1.1.5",
"version": "1.1.6",
"description": "BookTracker",
"scripts": {
"start": "craco start --mode staging",
Expand Down

0 comments on commit 6548f0e

Please sign in to comment.