0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-08-06 06:47:38 +00:00

snippet submenu triggers don't fire events onclick

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Gazook89
2026-04-23 10:42:58 -05:00
parent 2232d5265f
commit 3b6c7acdbf
@@ -2,6 +2,7 @@
import './snippetbar.less'; import './snippetbar.less';
import React from 'react'; import React from 'react';
import createReactClass from 'create-react-class'; import createReactClass from 'create-react-class';
import { Dropdown } from '../../../components/dropdown/dropdown.jsx';
import _ from 'lodash'; import _ from 'lodash';
import cx from 'classnames'; import cx from 'classnames';
@@ -189,6 +190,13 @@ const Snippetbar = createReactClass({
if(snippets.length === 0) return null; if(snippets.length === 0) return null;
return <div className='snippets'> return <div className='snippets'>
<Dropdown groupName='test' id='test-menu'>
<div>car</div>
<Dropdown groupName='submenu test' id='test-submenu'>
<div>bike</div>
<div>truck</div>
</Dropdown>
</Dropdown>
{_.map(snippets, (snippetGroup)=>{ {_.map(snippets, (snippetGroup)=>{
return <SnippetGroup return <SnippetGroup
brew={this.props.brew} brew={this.props.brew}
@@ -326,31 +334,30 @@ const SnippetGroup = createReactClass({
}, },
renderSnippets : function(snippets){ renderSnippets : function(snippets){
return _.map(snippets, (snippet)=>{ return _.map(snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}> if(!snippet.subsnippets){
<i className={snippet.icon} /> return (
<span className={`name${snippet.disabled ? ' disabled' : ''}`} title={snippet.name}>{snippet.name}</span> <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}>
{snippet.experimental && <span className='beta'>beta</span>} <i className={snippet.icon} />
{snippet.disabled && <span className='beta' title='temporarily disabled due to large slowdown; under re-design'>disabled</span>} <span className={`name${snippet.disabled ? ' disabled' : ''}`} title={snippet.name}>{snippet.name}</span>
{snippet.subsnippets && <> {snippet.experimental && <span className='beta'>beta</span>}
<i className='fas fa-caret-right'></i> {snippet.disabled && <span className='beta' title='temporarily disabled due to large slowdown; under re-design'>disabled</span>}
<div className='dropdown side'> </div>
);
} else if(snippet.subsnippets){
return (
<Dropdown groupName={snippet.name} className='dropdown side'>
{this.renderSnippets(snippet.subsnippets)} {this.renderSnippets(snippet.subsnippets)}
</div></>} </Dropdown>
</div>; )
}
}); });
}, },
render : function(){ render : function(){
const snippetGroup = `snippetGroup snippetBarButton ${this.props.snippets.length === 0 ? 'disabledSnippets' : ''}`; const snippetGroup = `snippetGroup snippetBarButton ${this.props.snippets.length === 0 ? 'disabledSnippets' : ''}`;
return <div className={snippetGroup}> return <Dropdown groupName={this.props.groupName} id={this.props.groupName} icon={this.props.icon} className={snippetGroup}>
<div className='text'> {this.renderSnippets(this.props.snippets)}
<i className={this.props.icon} /> </Dropdown>;
<span className='groupName'>{this.props.groupName}</span>
</div>
<div className='dropdown'>
{this.renderSnippets(this.props.snippets)}
</div>
</div>;
}, },
}); });