Skip to content

Commit

Permalink
feat(filter-menu): allow search value override
Browse files Browse the repository at this point in the history
  • Loading branch information
LuLaValva committed Nov 21, 2024
1 parent 495147f commit e92122a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/ebay-filter-menu-button/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ interface FilterMenuButtonInput
"form-method"?: string;
disabled?: boolean;
"a11y-text"?: AttrString;
"search-header-placeholder-text"?: string;
"a11y-search-header-clear-text"?: string;
"search-header-value"?: string;
"search-header-placeholder-text"?: AttrString;
"a11y-search-header-clear-text"?: AttrString;
"on-expand"?: () => void;
"on-change"?: (event: FilterMenuButtonEvent) => void;
"on-collapse"?: (event: FilterMenuButtonEvent) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export default {
category: "@attribute tags",
},
},
searchHeaderValue: {
control: { type: "text" },
description:
"optional value override for the input in the search header",
},
searchHeaderPlaceholderText: {
control: { type: "text" },
description:
Expand Down
2 changes: 2 additions & 0 deletions src/components/ebay-filter-menu-button/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $ const {
formAction,
formMethod,
items,
searchHeaderValue,
searchHeaderPlaceholderText,
a11ySearchHeaderClearText,
type: inputType,
Expand Down Expand Up @@ -48,6 +49,7 @@ $ const {
formMethod=formMethod
footerText=footerText
a11yFooterText=a11yFooterText
searchHeaderValue=searchHeaderValue
searchHeaderPlaceholderText=searchHeaderPlaceholderText
a11ySearchHeaderClearText=a11ySearchHeaderClearText
on-keydown("handleMenuKeydown")
Expand Down
12 changes: 9 additions & 3 deletions src/components/ebay-filter-menu/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ interface FilterMenuInput
"a11y-footer-text"?: AttrString;
}
>;
"search-header-placeholder-text"?: string;
"a11y-search-header-clear-text"?: string;
"search-header-value"?: string;
"search-header-placeholder-text"?: AttrString;
"a11y-search-header-clear-text"?: AttrString;
"render-body"?: Marko.Body;
"on-footer-click"?: (event: FilterMenuEvent) => void;
"on-form-submit"?: (event: FilterMenuEvent) => void;
Expand Down Expand Up @@ -121,7 +122,12 @@ export default class extends MenuUtils<Input, State> {
onInput(input: Input) {
this.state = {
...super.getInputState(input),
searchTerm: this.state ? this.state.searchTerm : "",
searchTerm:
input.searchHeaderValue !== undefined
? input.searchHeaderValue
: this.state
? this.state.searchTerm
: "",
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/components/ebay-filter-menu/filter-menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export default {
control: { type: "text" },
description: "forms `method` attribute",
},
searchHeaderValue: {
control: { type: "text" },
description:
"optional value override for the input in the search header",
},
searchHeaderPlaceholderText: {
control: { type: "text" },
description:
Expand Down
1 change: 1 addition & 0 deletions src/components/ebay-filter-menu/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $ const {
type,
ariaLabel,
ariaLabelledby,
searchHeaderValue,
searchHeaderPlaceholderText,
a11ySearchHeaderClearText,
...htmlInput
Expand Down

0 comments on commit e92122a

Please sign in to comment.