easysoft / easysoft/zui

[bug]日期选择框会出发modal的`show`,`hide`等事件

Open
#197 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.8k
Forks
678
Avg merge
6d 21h
Merged PRs (30d)
7

Description

测试代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/zui.min.css" />
    <link rel="stylesheet" href="./lib/datetimepicker/datetimepicker.css" />
</head>
<body>
    <div class="modal fade" id="timeModal">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
              <h4 class="modal-title">标题</h4>
            </div>
            <div class="modal-body">
              <form>
                  <input class="form-control form-date" name="started"/>
              </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
              <button type="button" class="btn btn-primary">保存</button>
            </div>
          </div>
        </div>
      </div>

      <button class="btn btn-primary" type="button" id="openModal">打开弹层</button>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="./js/zui.js"></script>
<script type="text/javascript" src="./lib/datetimepicker/datetimepicker.js"></script>
<script>
    $(function(){
        $(".form-date").datetimepicker(
            {
                weekStart: 1,
                todayBtn:  1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                forceParse: 0,
                format: "yyyy-mm-dd HH:ii:ss"
            }
        );

        $('#openModal').on('click', function(){
            $('#timeModal').modal('show');
        });
        $('#timeModal').on('hide.zui.modal', function(){
            console.log('hide')
            $('#timeModal input[name=started]').val('');
        });
    })
</script>
</body>
</html>

原本监听的弹窗关闭事件,关闭时清空input框内容,但是选择日期后,input框没有显示所选日期,同时控制台输出hide,这原本应该是弹窗关闭时输出的

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the supplied HTML reproduction with js/zui.js and lib/datetimepicker/datetimepicker.js loaded. Start by running it and tracing the date picker interaction alongside the #timeModal hide.zui.modal handler. Done means selecting a date keeps the selected value in the input without triggering the modal hide handler, while closing the modal still triggers that handler.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.