Skip to content

Commit

Permalink
fix: allow submit when pressing enter key in search blocks (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrina-bongiovanni authored Dec 27, 2023
1 parent 7185d09 commit 39ca6e5
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 129 deletions.
92 changes: 49 additions & 43 deletions src/components/ItaliaTheme/Blocks/BandiSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,54 +153,60 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => {
'public-ui': inEditMode,
})}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
<form
onSubmit={(event) => {
event.preventDefault();
doRequest(1);
}}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
dispatchFilter({
filter: filter,
value: value,
});
},
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
});
},
}),
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
onClick={() => doRequest(1)}
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
</div>
</div>
</div>
</form>
</div>

{!loading ? (
Expand Down
92 changes: 49 additions & 43 deletions src/components/ItaliaTheme/Blocks/EventSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,54 +164,60 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => {
'public-ui': inEditMode,
})}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
<form
onSubmit={(event) => {
event.preventDefault();
doRequest(1);
}}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
dispatchFilter({
filter: filter,
value: value,
});
},
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
});
},
}),
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
onClick={() => doRequest(1)}
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
</div>
</div>
</div>
</form>
</div>

{!loading ? (
Expand Down
92 changes: 49 additions & 43 deletions src/components/ItaliaTheme/Blocks/UOSearch/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,54 +147,60 @@ const Body = ({ data, inEditMode, path, onChangeBlock }) => {
'public-ui': inEditMode,
})}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
<form
onSubmit={(event) => {
event.preventDefault();
doRequest(1);
}}
>
<div className="d-flex justify-content-center">
<div className="d-flex search-container align-items-center justify-content-center flex-wrap">
{filterOne && (
<>
{React.createElement(filterOne.widget.component, {
...filterOne.widget?.props,
id: 'filterOne',
onChange: (filter, value) => {
dispatchFilter({
filter: filter,
value: value,
});
},
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
});
},
}),
})}
</>
)}
{filterTwo &&
React.createElement(filterTwo.widget?.component, {
...filterTwo.widget?.props,
id: 'filterTwo',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
onClick={() => doRequest(1)}
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
{filterThree &&
React.createElement(filterThree.widget?.component, {
...filterThree.widget?.props,
id: 'filterThree',
onChange: (filter, value) =>
dispatchFilter({
filter: filter,
value: value,
}),
})}

<Button
color={data.button_color || 'tertiary'}
icon={false}
tag="button"
className="my-2 my-lg-1"
>
{intl.formatMessage(messages.find)}
</Button>
</div>
</div>
</div>
</form>
</div>

{!loading ? (
Expand Down

0 comments on commit 39ca6e5

Please sign in to comment.