Skip to content

Commit

Permalink
feat: 修复 react 中 click 事件重复触发的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaocun1 committed Nov 2, 2022
1 parent 63c7c5c commit 3480cd0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/quark-reactify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
}

update() {
this.clearEventHandlers();
this.clearEventHandlers();
if (!this.ref.current) return;
//@ts-ignore
Object.entries(this.props).forEach(([prop, val]) => {
if (typeof val === 'function') {
if (prop.match(/^on[A-Za-z]/)) {
return this.setEvent(prop.substr(2).toLowerCase(), val);
// 需要过滤掉原生支持的 click 事件
const eventName = prop.substr(2).toLowerCase();
if (eventName !== 'click') {
return this.setEvent(eventName, val);
}
}
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/quark/src/navbar/doc-react.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export default () => {
<Navbar
right="share"
title="Click left or right"
onLeftclick={onLeftClick}
onRightclick={onRightClick}
onLeftClick={onLeftClick}
onRightClick={onRightClick}
onClose={close}
/>
)
Expand Down
3 changes: 2 additions & 1 deletion packages/quark/src/navbar/style.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
:host {
display: block;
font-size: 18px;
height: 44px;
position: relative;
display: flex;
align-items: center;
color: quark-textBaseColor;
text-align: center;
width: 100%;
background-color: white;
}

:host([safearea]) {
Expand Down

0 comments on commit 3480cd0

Please sign in to comment.