反应-单击摘要子级仅触发箭头动画

时间:2019-09-16 16:12:03

标签: javascript html reactjs

如您在我的gif上看到的那样,在问题的结尾,当我单击<property name="environment" value="${env.GAH_ENV}"/> 文本时,它会正确显示其子级并触发箭头动画。但是,当单击子级文本时,它仅触发箭头动画,而不会隐藏子级。我不想隐藏孩子,也不会触发动画。这是我的<summary>组件的代码:

<Accordion>

这是我的 handleClick = (event: SyntheticEvent) => { const { onSummaryClick: onClick } = this.props this.setState(state => ({ open: !state.open })) if (onClick) { event.persist() onClick(event) } } handleKeyDown = (event: KeyboardEvent) => { const { handleClick } = this if (event.key === KEYS.ENTER) { handleClick(event) } } render() { const { children, summary, defaultOpen } = this.props const { open } = this.state const { handleClick, handleKeyDown, isNativelySupported } = this const closeAccordionInUnsupportedBrowser = !isNativelySupported && !open return ( <details onClick={handleClick} onKeyDown={isNativelySupported ? undefined : handleKeyDown} open={defaultOpen} className={padding.horizontalTwo} > <Summary text={summary} open={open} /> {closeAccordionInUnsupportedBrowser ? null : children} </details> ) } 组件的代码:

<Summary>

enter image description here

0 个答案:

没有答案