From 07aa9b6738168928ff40f2bae62b65dc067907a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dante=20=C3=81lvarez?=
<89805481+danalvrz@users.noreply.github.com>
Date: Wed, 9 Aug 2023 12:19:01 -0600
Subject: [PATCH 1/7] hide search block fields
---
.../Blocks/Search/TopSideFacets.jsx | 60 ++++++++++---------
src/theme/blocks/_search.scss | 14 +++++
2 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/src/components/Blocks/Search/TopSideFacets.jsx b/src/components/Blocks/Search/TopSideFacets.jsx
index 1747f696..f6140e90 100644
--- a/src/components/Blocks/Search/TopSideFacets.jsx
+++ b/src/components/Blocks/Search/TopSideFacets.jsx
@@ -81,35 +81,37 @@ const TopSideFacets = (props) => {
total={totalItems}
as="h5"
/>
-
-
- {intl.formatMessage(messages.sort)}
-
- {
- flushSync(() => {
- setSortOn(sortOn);
- onTriggerSearch(searchedText || '', facets, sortOn);
- });
- }}
- setSortOrder={(sortOrder) => {
- flushSync(() => {
- setSortOrder(sortOrder);
- onTriggerSearch(
- searchedText || '',
- facets,
- sortOn,
- sortOrder,
- );
- });
- }}
- />
-
+ {data.sortOnOptions.length > 0 && (
+
+
+ {intl.formatMessage(messages.sort)}
+
+ {
+ flushSync(() => {
+ setSortOn(sortOn);
+ onTriggerSearch(searchedText || '', facets, sortOn);
+ });
+ }}
+ setSortOrder={(sortOrder) => {
+ flushSync(() => {
+ setSortOrder(sortOrder);
+ onTriggerSearch(
+ searchedText || '',
+ facets,
+ sortOn,
+ sortOrder,
+ );
+ });
+ }}
+ />
+
+ )}
)}
diff --git a/src/theme/blocks/_search.scss b/src/theme/blocks/_search.scss
index 38a71f2a..51393ab5 100644
--- a/src/theme/blocks/_search.scss
+++ b/src/theme/blocks/_search.scss
@@ -240,3 +240,17 @@
}
}
}
+
+// Hidden fields
+#blockform-fieldset-views {
+ display: none;
+}
+
+.inline.field {
+ &.field-wrapper-showSearchInput,
+ &.field-wrapper-showSearchButton,
+ &.field-wrapper-showTotalResults,
+ &.field-wrapper-showSortOn {
+ display: none;
+ }
+}
From 77d6f4d557695d9de4d921390515e02fff999eea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dante=20=C3=81lvarez?=
<89805481+danalvrz@users.noreply.github.com>
Date: Wed, 9 Aug 2023 12:21:05 -0600
Subject: [PATCH 2/7] changelog
---
news/213.bugfix | 1 +
1 file changed, 1 insertion(+)
create mode 100644 news/213.bugfix
diff --git a/news/213.bugfix b/news/213.bugfix
new file mode 100644
index 00000000..fddb4cd6
--- /dev/null
+++ b/news/213.bugfix
@@ -0,0 +1 @@
+Hide unnecessary Search block fields. @danalvrz
\ No newline at end of file
From 1c58b7a2a4aec3aaa738a42bf5a92874e25adfc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dante=20=C3=81lvarez?=
<89805481+danalvrz@users.noreply.github.com>
Date: Wed, 9 Aug 2023 14:25:48 -0600
Subject: [PATCH 3/7] add search block schema enhancer
---
src/components/Blocks/Search/schema.js | 7 +++++++
src/index.js | 22 ++++++++++++++--------
src/theme/blocks/_search.scss | 4 ----
3 files changed, 21 insertions(+), 12 deletions(-)
create mode 100644 src/components/Blocks/Search/schema.js
diff --git a/src/components/Blocks/Search/schema.js b/src/components/Blocks/Search/schema.js
new file mode 100644
index 00000000..86b4f474
--- /dev/null
+++ b/src/components/Blocks/Search/schema.js
@@ -0,0 +1,7 @@
+export const searchBlockSchemaEnhancer = ({ schema, formData, intl }) => {
+ schema.properties.showSortOn.default = true;
+ schema.properties.sortOnOptions.default = ['sortable_title', 'effective'];
+ schema.fieldsets = schema.fieldsets.filter((item) => item.id !== 'views');
+
+ return schema;
+};
diff --git a/src/index.js b/src/index.js
index f51934c2..1df69fba 100644
--- a/src/index.js
+++ b/src/index.js
@@ -20,6 +20,8 @@ import { ImageBlockDataAdapter } from './components/Blocks/Image/adapter';
import { AccordionSchemaEnhancer } from './components/Blocks/Accordion/schema';
+import { searchBlockSchemaEnhancer } from './components/Blocks/Search/schema';
+
import gridSVG from './icons/block_icn_grid.svg';
import accordionSVG from './icons/block_icn_accordion.svg';
import EventView from './components/Theme/EventView';
@@ -264,14 +266,18 @@ const applyConfig = (config) => {
schemaEnhancer: defaultStylingSchema,
};
- config.blocks.blocksConfig.search.variations = [
- {
- id: 'facetsTopSide',
- title: 'Facets on top',
- view: TopSideFacets,
- isDefault: true,
- },
- ];
+ config.blocks.blocksConfig.search = {
+ ...config.blocks.blocksConfig.search,
+ schemaEnhancer: searchBlockSchemaEnhancer,
+ variations: [
+ {
+ id: 'facetsTopSide',
+ title: 'Facets on top',
+ view: TopSideFacets,
+ isDefault: true,
+ },
+ ],
+ };
config.blocks.blocksConfig.__button = {
...config.blocks.blocksConfig.__button,
diff --git a/src/theme/blocks/_search.scss b/src/theme/blocks/_search.scss
index 51393ab5..7e288f1b 100644
--- a/src/theme/blocks/_search.scss
+++ b/src/theme/blocks/_search.scss
@@ -242,10 +242,6 @@
}
// Hidden fields
-#blockform-fieldset-views {
- display: none;
-}
-
.inline.field {
&.field-wrapper-showSearchInput,
&.field-wrapper-showSearchButton,
From 2baa0e55583faa2c8319de5de5206010dd603783 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dante=20=C3=81lvarez?=
<89805481+danalvrz@users.noreply.github.com>
Date: Wed, 9 Aug 2023 14:31:55 -0600
Subject: [PATCH 4/7] add bottom border to last result item
---
src/theme/blocks/_search.scss | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/theme/blocks/_search.scss b/src/theme/blocks/_search.scss
index 7e288f1b..48538c3b 100644
--- a/src/theme/blocks/_search.scss
+++ b/src/theme/blocks/_search.scss
@@ -6,6 +6,11 @@
.card-container > img {
width: 100% !important;
}
+
+ .listing-item:last-child {
+ padding-bottom: 0;
+ border-bottom: none;
+ }
}
.items {
padding: 0 !important;
@@ -23,6 +28,10 @@
color: $black;
@include text-heading-h2();
}
+ &:last-child {
+ padding-bottom: 40px;
+ border-bottom: 1px solid $black;
+ }
&:not(.grid) {
img {
From 4476868a36b965de82655487dd3e5bc51990b6db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dante=20=C3=81lvarez?=
<89805481+danalvrz@users.noreply.github.com>
Date: Wed, 9 Aug 2023 14:38:02 -0600
Subject: [PATCH 5/7] lint
---
src/theme/blocks/_search.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/theme/blocks/_search.scss b/src/theme/blocks/_search.scss
index 48538c3b..699a4938 100644
--- a/src/theme/blocks/_search.scss
+++ b/src/theme/blocks/_search.scss
@@ -6,7 +6,7 @@
.card-container > img {
width: 100% !important;
}
-
+
.listing-item:last-child {
padding-bottom: 0;
border-bottom: none;
From 66a81e5b9a6bc9b357e9d55e68a5c1077ce31944 Mon Sep 17 00:00:00 2001
From: David Glick
Date: Wed, 9 Aug 2023 15:39:50 -0700
Subject: [PATCH 6/7] handle missing sortOnOptions
---
src/components/Blocks/Search/TopSideFacets.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Blocks/Search/TopSideFacets.jsx b/src/components/Blocks/Search/TopSideFacets.jsx
index f6140e90..be8a6018 100644
--- a/src/components/Blocks/Search/TopSideFacets.jsx
+++ b/src/components/Blocks/Search/TopSideFacets.jsx
@@ -81,7 +81,7 @@ const TopSideFacets = (props) => {
total={totalItems}
as="h5"
/>
- {data.sortOnOptions.length > 0 && (
+ {data.sortOnOptions && data.sortOnOptions.length > 0 && (
{intl.formatMessage(messages.sort)}
From d76444e52a90647e9583eec45faacdd5806aec7f Mon Sep 17 00:00:00 2001
From: David Glick
Date: Wed, 9 Aug 2023 15:48:58 -0700
Subject: [PATCH 7/7] remove broken default, fix width in edit mode
---
src/components/Blocks/Search/schema.js | 1 -
src/theme/_layout.scss | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/components/Blocks/Search/schema.js b/src/components/Blocks/Search/schema.js
index 86b4f474..a5ca3afb 100644
--- a/src/components/Blocks/Search/schema.js
+++ b/src/components/Blocks/Search/schema.js
@@ -1,6 +1,5 @@
export const searchBlockSchemaEnhancer = ({ schema, formData, intl }) => {
schema.properties.showSortOn.default = true;
- schema.properties.sortOnOptions.default = ['sortable_title', 'effective'];
schema.fieldsets = schema.fieldsets.filter((item) => item.id !== 'views');
return schema;
diff --git a/src/theme/_layout.scss b/src/theme/_layout.scss
index 6e4ceb47..398ccbeb 100644
--- a/src/theme/_layout.scss
+++ b/src/theme/_layout.scss
@@ -266,6 +266,8 @@ footer {
.block.heading .heading-wrapper,
.block-editor-listing .items,
.block-editor-listing .listing.message,
+ .block-editor-search .listing-item,
+ .block-editor-search .search-input-resultscount-sort,
.block-editor-separator.has--align--full .block.separator,
.block-editor-separator .block.separator.has--align--full,
.block.teaser.has--align--center,