From fccc5945bd0a33e32182f18ac6bb6f8b4781c285 Mon Sep 17 00:00:00 2001 From: syc0123 Date: Thu, 26 Mar 2026 14:43:37 +0900 Subject: [PATCH] =?UTF-8?q?[RAPID-fix]=20=EC=BB=AC=EB=9F=BC=20=EB=A6=AC?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=A6=88=20colgroup=20=EC=97=B0=EB=8F=99,=20?= =?UTF-8?q?Select2=20=EB=93=9C=EB=9E=98=EA=B7=B8=20=EB=B3=B5=EC=82=AC=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컬럼 리사이즈: col 요소와 th를 동시에 수정하여 table-layout:fixed에서 동작 - Select2 드래그 복사: mousedown 시 열림 방지, 클릭(mouseup)으로만 열리게 변경 - 드래그 시 텍스트 선택만 되고 드롭다운 안 열림 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../estimateAndOrderRegistFormPopup.jsp | 54 +++++++++++-------- .../contractMgmt/estimateRegistFormPopup.jsp | 54 +++++++++++-------- 2 files changed, 62 insertions(+), 46 deletions(-) diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp index 6131974..87c0aaf 100644 --- a/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp +++ b/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp @@ -105,22 +105,27 @@ } }); - var startX, startWidth, $th; + var startX, startWidth, $th, colIndex, $col; $(document).on('mousedown', '#itemListTable .col-resizer', function(e) { $th = $(this).parent(); + colIndex = $th.index(); + $col = $table.find('colgroup col').eq(colIndex); startX = e.pageX; startWidth = $th.outerWidth(); + $('body').css('cursor', 'col-resize'); + $(document).on('mousemove.colResize', function(e) { var newWidth = startWidth + (e.pageX - startX); if(newWidth >= 40) { - $th.css('width', newWidth + 'px'); - $th.css('min-width', newWidth + 'px'); + $col.css('width', newWidth + 'px'); + $th.css({'width': newWidth + 'px', 'min-width': newWidth + 'px'}); } }); $(document).on('mouseup.colResize', function() { + $('body').css('cursor', ''); $(document).off('mousemove.colResize mouseup.colResize'); }); @@ -131,34 +136,37 @@ // ===== Select2 드래그 복사 지원 ===== function fn_initSelect2DragCopy() { - var isDragging = false; - var startX = 0, startY = 0; + // Select2의 기본 mousedown 열림을 차단하고, click(mouseup)으로만 열리게 변경 + $(document).on('mousedown', '#itemListTable .select2-container', function(e) { + // select2-selection__clear(x버튼)은 그대로 동작 + if($(e.target).hasClass('select2-selection__clear')) return; - // 품목 그리드 내 Select2에만 적용 - $(document).on('mousedown', '#itemListTable .select2-selection', function(e) { - isDragging = false; - startX = e.pageX; - startY = e.pageY; + var $container = $(this); + var $select = $container.prev('select'); + var startX = e.pageX, startY = e.pageY; + var wasDragged = false; - $(document).on('mousemove.s2drag', function(e) { - var dx = Math.abs(e.pageX - startX); - var dy = Math.abs(e.pageY - startY); - if(dx > 5 || dy > 5) { - isDragging = true; + // Select2 열림 방지 (mousedown 시점) + $select.on('select2:opening.dragcopy', function(ev) { + ev.preventDefault(); + }); + + $(document).on('mousemove.s2drag', function(ev) { + if(Math.abs(ev.pageX - startX) > 3 || Math.abs(ev.pageY - startY) > 3) { + wasDragged = true; } }); $(document).on('mouseup.s2drag', function() { - setTimeout(function() { isDragging = false; }, 100); $(document).off('mousemove.s2drag mouseup.s2drag'); - }); - }); + // 방지 해제 + $select.off('select2:opening.dragcopy'); - // 드래그 중이면 Select2 열림 방지 - $(document).on('select2:opening', '#itemListTable select', function(e) { - if(isDragging) { - e.preventDefault(); - } + // 드래그가 아니면 (클릭이면) Select2 열기 + if(!wasDragged) { + setTimeout(function() { $select.select2('open'); }, 10); + } + }); }); } diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp index 79804a1..07d11e0 100644 --- a/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp +++ b/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp @@ -106,22 +106,27 @@ } }); - var startX, startWidth, $th; + var startX, startWidth, $th, colIndex, $col; $(document).on('mousedown', '#itemListTable .col-resizer', function(e) { $th = $(this).parent(); + colIndex = $th.index(); + $col = $table.find('colgroup col').eq(colIndex); startX = e.pageX; startWidth = $th.outerWidth(); + $('body').css('cursor', 'col-resize'); + $(document).on('mousemove.colResize', function(e) { var newWidth = startWidth + (e.pageX - startX); if(newWidth >= 40) { - $th.css('width', newWidth + 'px'); - $th.css('min-width', newWidth + 'px'); + $col.css('width', newWidth + 'px'); + $th.css({'width': newWidth + 'px', 'min-width': newWidth + 'px'}); } }); $(document).on('mouseup.colResize', function() { + $('body').css('cursor', ''); $(document).off('mousemove.colResize mouseup.colResize'); }); @@ -132,34 +137,37 @@ // ===== Select2 드래그 복사 지원 ===== function fn_initSelect2DragCopy() { - var isDragging = false; - var startX = 0, startY = 0; + // Select2의 기본 mousedown 열림을 차단하고, click(mouseup)으로만 열리게 변경 + $(document).on('mousedown', '#itemListTable .select2-container', function(e) { + // select2-selection__clear(x버튼)은 그대로 동작 + if($(e.target).hasClass('select2-selection__clear')) return; - // 품목 그리드 내 Select2에만 적용 - $(document).on('mousedown', '#itemListTable .select2-selection', function(e) { - isDragging = false; - startX = e.pageX; - startY = e.pageY; + var $container = $(this); + var $select = $container.prev('select'); + var startX = e.pageX, startY = e.pageY; + var wasDragged = false; - $(document).on('mousemove.s2drag', function(e) { - var dx = Math.abs(e.pageX - startX); - var dy = Math.abs(e.pageY - startY); - if(dx > 5 || dy > 5) { - isDragging = true; + // Select2 열림 방지 (mousedown 시점) + $select.on('select2:opening.dragcopy', function(ev) { + ev.preventDefault(); + }); + + $(document).on('mousemove.s2drag', function(ev) { + if(Math.abs(ev.pageX - startX) > 3 || Math.abs(ev.pageY - startY) > 3) { + wasDragged = true; } }); $(document).on('mouseup.s2drag', function() { - setTimeout(function() { isDragging = false; }, 100); $(document).off('mousemove.s2drag mouseup.s2drag'); - }); - }); + // 방지 해제 + $select.off('select2:opening.dragcopy'); - // 드래그 중이면 Select2 열림 방지 - $(document).on('select2:opening', '#itemListTable select', function(e) { - if(isDragging) { - e.preventDefault(); - } + // 드래그가 아니면 (클릭이면) Select2 열기 + if(!wasDragged) { + setTimeout(function() { $select.select2('open'); }, 10); + } + }); }); }