From b6b5183f21f64549f88494eb6dac52d06ca74301 Mon Sep 17 00:00:00 2001 From: anoshenko Date: Thu, 4 May 2023 13:37:26 +0300 Subject: [PATCH] Bug fixing --- app_scripts.js | 26 ++++++++++++++------------ tabsLayout.go | 7 +------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app_scripts.js b/app_scripts.js index 20de4af..280977c 100644 --- a/app_scripts.js +++ b/app_scripts.js @@ -242,22 +242,26 @@ function enterOrSpaceKeyClickEvent(event) { function activateTab(layoutId, tabNumber) { var element = document.getElementById(layoutId); if (element) { - var currentTabId = element.getAttribute("data-current"); - var newTabId = layoutId + '-' + tabNumber; - if (currentTabId != newTabId) { - function setTab(tabId, styleProperty, display) { - var tab = document.getElementById(tabId); + var currentNumber = element.getAttribute("data-current"); + if (currentNumber != tabNumber) { + function setTab(number, styleProperty, display) { + var tab = document.getElementById(layoutId + '-' + number); if (tab) { tab.className = element.getAttribute(styleProperty); var page = document.getElementById(tab.getAttribute("data-view")); if (page) { page.style.display = display; } + return + } + var page = document.getElementById(layoutId + "-page" + number); + if (page) { + page.style.display = display; } } - setTab(currentTabId, "data-inactiveTabStyle", "none") - setTab(newTabId, "data-activeTabStyle", ""); - element.setAttribute("data-current", newTabId); + setTab(currentNumber, "data-inactiveTabStyle", "none") + setTab(tabNumber, "data-activeTabStyle", ""); + element.setAttribute("data-current", tabNumber); scanElementsSize() } } @@ -1557,6 +1561,8 @@ function tableViewCellKeyDownEvent(element, event) { case "End": case "PageUp": case "PageDown": + event.stopPropagation(); + event.preventDefault(); const rows = element.getAttribute("data-rows"); const columns = element.getAttribute("data-columns"); if (rows && columns) { @@ -1567,8 +1573,6 @@ function tableViewCellKeyDownEvent(element, event) { column = 0; while (columns < columnCount) { if (setTableCellCursor(element, row, column)) { - event.stopPropagation(); - event.preventDefault(); return; } column++; @@ -1576,8 +1580,6 @@ function tableViewCellKeyDownEvent(element, event) { row++; } } - event.stopPropagation(); - event.preventDefault(); break; } return; diff --git a/tabsLayout.go b/tabsLayout.go index 0f48d90..e880aa7 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -1,7 +1,6 @@ package rui import ( - "fmt" "strconv" "strings" ) @@ -650,10 +649,6 @@ func (tabsLayout *tabsLayoutData) RemoveView(index int) View { return view } -func (tabsLayout *tabsLayoutData) currentID() string { - return fmt.Sprintf("%s-%d", tabsLayout.htmlID(), tabsLayout.currentItem(0)) -} - func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Builder) { tabsLayout.viewsContainerData.htmlProperties(self, buffer) buffer.WriteString(` data-inactiveTabStyle="`) @@ -661,7 +656,7 @@ func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Buil buffer.WriteString(`" data-activeTabStyle="`) buffer.WriteString(tabsLayout.activeTabStyle()) buffer.WriteString(`" data-current="`) - buffer.WriteString(tabsLayout.currentID()) + buffer.WriteString(strconv.Itoa(tabsLayout.currentItem(0))) buffer.WriteRune('"') }