From 2a0b442921398046f0bb0690d3bc95d62bc7186d Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 21 Apr 2023 10:50:40 +0800 Subject: [PATCH] fix: fix click link in the modal-button Fix no jump when click the link in the modal of the modal-button component Change-Id: I13c8b2a47a89c978d44f6aa6ba33aa1156b9e464 --- src/components/ModalButton/index.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ModalButton/index.jsx b/src/components/ModalButton/index.jsx index 66b8da92..09c6183e 100644 --- a/src/components/ModalButton/index.jsx +++ b/src/components/ModalButton/index.jsx @@ -189,21 +189,23 @@ export default class ModalButton extends Component { return; } const buttons = this.modalTarget.getElementsByTagName('button'); + const links = this.modalTarget.getElementsByTagName('a'); + const elements = [...buttons, ...links]; const { innerHTML = '' } = e.target || {}; - let isButton = false; - for (let i = 0; i < buttons.length; i++) { - if (isButton) { + let isClickable = false; + const specialInner = ['-', '']; + for (let i = 0; i < elements.length; i++) { + if (isClickable) { return; } - const specialInner = ['-', '']; if ( !specialInner.includes(innerHTML) && - buttons[i].innerHTML.includes(innerHTML) + elements[i].innerHTML.includes(innerHTML) ) { - isButton = true; + isClickable = true; } } - if (isButton) { + if (isClickable) { return; } this.stopEvent(e);