Browse Source

fix(ui): Clearing image filter search may crash the React app (#18978)

* Fixes JAVASCRIPT-224R

Co-authored-by: Matej Minar <matej.minar@sentry.io>
Alberto Leal 4 years ago
parent
commit
602e112895

+ 1 - 0
src/sentry/static/sentry/app/components/events/interfaces/debugmeta.jsx

@@ -319,6 +319,7 @@ class DebugMetaInterface extends React.PureComponent {
 
   filterImage(image) {
     const {showUnused, filter} = this.state;
+
     if (!filter || filter.length < MIN_FILTER_LEN) {
       if (showUnused) {
         return true;

+ 18 - 12
src/sentry/static/sentry/app/components/events/interfaces/imageForBar.tsx

@@ -9,20 +9,26 @@ import {t} from 'app/locale';
 
 type Props = {
   frame: Frame;
-  onShowAllImages: () => void;
+  onShowAllImages: (filter: string) => void;
 };
 
-const ImageForBar = ({frame, onShowAllImages}: Props) => (
-  <Wrapper>
-    <MatchedFunctionWrapper>
-      <MatchedFunctionCaption>{t('Image for: ')}</MatchedFunctionCaption>
-      <FrameFunctionName frame={frame} />
-    </MatchedFunctionWrapper>
-    <ResetAddressFilterCaption onClick={onShowAllImages}>
-      {t('Show all images')}
-    </ResetAddressFilterCaption>
-  </Wrapper>
-);
+const ImageForBar = ({frame, onShowAllImages}: Props) => {
+  const handleShowAllImages = () => {
+    onShowAllImages('');
+  };
+
+  return (
+    <Wrapper>
+      <MatchedFunctionWrapper>
+        <MatchedFunctionCaption>{t('Image for: ')}</MatchedFunctionCaption>
+        <FrameFunctionName frame={frame} />
+      </MatchedFunctionWrapper>
+      <ResetAddressFilterCaption onClick={handleShowAllImages}>
+        {t('Show all images')}
+      </ResetAddressFilterCaption>
+    </Wrapper>
+  );
+};
 
 ImageForBar.propTypes = {
   frame: PropTypes.object.isRequired,