如果用户两次选择同一项目,则ReactJS语义UI下拉菜单onChange不会触发

时间:2019-05-31 09:28:47

标签: javascript reactjs dropdown onchange semantic-ui

我有一个文件菜单,其中包含3个选项:

const fileOptions = [
  { key: 'open', icon: 'open folder outline', text: 'Open lesson', value: 'open' },
  { key: 'save', icon: 'save', text: 'Save lesson', value: 'save' },
  { key: 'delete', icon: 'delete', text: 'Delete lesson', value: 'delete' },
]

一切正常,但是如果我两次选择“保存课程”,它将只在第一次使用(我正在使用onChange事件)。那是因为下拉菜单的值没有改变。我应该usr什么事件?

     <Button.Group color='teal'>
        <Dropdown

          className='button icon'
          floating
          options={fileOptions}
          trigger={<React.Fragment />}
          onChange={this.handleLessonMenu}
        />
      </Button.Group>

2 个答案:

答案 0 :(得分:1)

我通过如下更改代码来解决问题:

public void Publish(Order message)
        {
            using (var queue = new MessageQueue("FormatName:MULTICAST=224.0.0.1:8001"))
            {
                //Below line of code which is commented throws error and doen't see any MessageQueue overloads that accept MachineName
                //ERROR :: The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted.
                //queue.MachineName = "BPN-BSD-S0071"; //ERROR
                var msmqMessage = new Message
                {
                    BodyStream = message.ToJsonStream(),
                    Label = message.GetMessageType(),
                    Recoverable = true
                };
                queue.Send(msmqMessage);
            }
        }

答案 1 :(得分:0)

尝试使用 onClick 事件而不是 onChange 。因此,每当您单击该选项时,它就会被触发。