[Masthead]: searchNoRedirect prop still not working properly #8833
Labels
adopter support
bug
Something isn't working
dev
Needs some dev work
package: react
Work necessary for the Carbon for IBM.com react components package
severity 2
Affects major functionality, has a workaround
Description
This is a follow-on to issue #8334
searchNoRedirect
prop of<Masthead>
successfully prevents the redirect. However, it does not emit custom eventonSearchNoRedirect
correctly.As per documentation,
onSearchNoRedirect
event should emitvalue
andmethod
.value
is only being emittedonClick
. The event emits no valueonEnter
, resulting invalue
beingundefined
.method
is not emitted at all. It is alwaysundefined
.As per Masthead documentation,
value
andmethod
should be emitted bothonClick
andonEnter
.// disables search redirect onClick and onEnter
document.addEventListener('onSearchNoRedirect', e => console.log(e.detail);
// { suggestion, value: inputValue, method: 'click'|'enter' });
Component(s) impacted
Masthead
Browser
Chrome, Safari, Firefox, Microsoft Edge
Carbon for IBM.com version
1.33.1
Severity
Severity 2 = Aspects of design is broken, and impedes users in a significant way, but there is a way to complete their tasks. Affects major functionality, has a workaround.
Application/website
https://www.redbooks.ibm.com
Package
@carbon/ibmdotcom-react
CodeSandbox example
https://githubbox.com/carbon-design-system/carbon-for-ibm-dotcom/tree/main/packages/react/examples/codesandbox/components/MastheadL1
Steps to reproduce the issue (if applicable)
<Masthead searchNoRedirect />
onSearchNoRedirect
, readvalue
andmethod
Enter
key. Bothvalue
andmethod
returnundefined
.value
returns keyword correctly butmethod
returnsundefined
.const doSearch = useCallback((e) => {
console.log("value: " + e.detail.value);
console.log("method: " + e.detail.method);
});
React.useEffect(() => {
window.addEventListener("onSearchNoRedirect", doSearch);
return function cleanup() {
window.removeEventListener("onSearchNoRedirect", doSearch);
};
});
Release date (if applicable)
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: