Repository navigation
Conversation
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
There was a problem hiding this comment.
Code Review
This pull request introduces a tab overflow management system for the IDE layout manager, including horizontal scrolling of tabs via vertical wheel events, an overflow dropdown menu listing all tabs, and a reveal option to restore maximized panes when focusing a hidden component. The feedback suggests making the exported wheelDeltaPx utility backward-compatible to prevent runtime errors in external callers, and adding an early return in _onMenuKey to avoid division-by-zero (NaN) errors when the tab menu is empty.
| export function wheelDeltaPx(e, pagePx) { | ||
| const kLineHeightPx = 16; | ||
| let scale = 1; | ||
| if (e.deltaMode === 1) { | ||
| scale = kLineHeightPx; | ||
| } else if (e.deltaMode === 2) { | ||
| scale = container.clientHeight || kLineHeightPx; | ||
| scale = pagePx() || kLineHeightPx; | ||
| } | ||
| return [e.deltaX * scale, e.deltaY * scale]; | ||
| } |
There was a problem hiding this comment.
The signature of wheelDeltaPx has been changed from accepting a DOM element (container) to a function (pagePx). Since wheelDeltaPx is an exported utility function, this breaking change could cause runtime errors (TypeError: pagePx is not a function) if other modules or external plugins call it using the old signature. Making it backward-compatible by checking the type of pagePx ensures robustness and prevents crashes.
| export function wheelDeltaPx(e, pagePx) { | |
| const kLineHeightPx = 16; | |
| let scale = 1; | |
| if (e.deltaMode === 1) { | |
| scale = kLineHeightPx; | |
| } else if (e.deltaMode === 2) { | |
| scale = container.clientHeight || kLineHeightPx; | |
| scale = pagePx() || kLineHeightPx; | |
| } | |
| return [e.deltaX * scale, e.deltaY * scale]; | |
| } | |
| export function wheelDeltaPx(e, pagePx) { | |
| const kLineHeightPx = 16; | |
| let scale = 1; | |
| if (e.deltaMode === 1) { | |
| scale = kLineHeightPx; | |
| } else if (e.deltaMode === 2) { | |
| scale = (typeof pagePx === 'function' ? pagePx() : pagePx?.clientHeight) || kLineHeightPx; | |
| } | |
| return [e.deltaX * scale, e.deltaY * scale]; | |
| } |
| _onMenuKey(e) { | ||
| const menu = this.renderRoot.querySelector('.ide-tab-menu'); | ||
| if (!menu || !e.composedPath().includes(menu)) return; | ||
| const items = [...menu.querySelectorAll('.ide-tab-menu-item')]; | ||
| const n = items.length; | ||
| const i = items.indexOf(this.renderRoot.activeElement); | ||
| let target = null; | ||
| if (e.key === 'ArrowDown') { | ||
| target = items[(i + 1) % n]; | ||
| } else if (e.key === 'ArrowUp') { | ||
| target = items[i <= 0 ? n - 1 : i - 1]; | ||
| } else if (e.key === 'Home') { | ||
| target = items[0]; | ||
| } else if (e.key === 'End') { | ||
| target = items[n - 1]; | ||
| } else if (e.key.length === 1 && e.key !== ' ' && !e.ctrlKey && !e.metaKey && !e.altKey) { | ||
| // Type-ahead: the next item whose title starts with the letter. | ||
| const letter = e.key.toLowerCase(); | ||
| target = [...items.slice(i + 1), ...items.slice(0, i + 1)].find(item => | ||
| item.querySelector('.ide-tab-menu-title').textContent.toLowerCase().startsWith(letter)); | ||
| } else if (e.key !== 'Escape') { | ||
| return; | ||
| } |
There was a problem hiding this comment.
To prevent potential runtime errors and division-by-zero (NaN) issues when navigating the menu via keyboard shortcuts, we should add an early return if the menu contains no items. Additionally, using optional chaining when querying the .ide-tab-menu-title element adds extra robustness in case the DOM structure of the menu item is ever customized or modified.
_onMenuKey(e) {
const menu = this.renderRoot.querySelector('.ide-tab-menu');
if (!menu || !e.composedPath().includes(menu)) return;
const items = [...menu.querySelectorAll('.ide-tab-menu-item')];
const n = items.length;
if (n === 0) return;
const i = items.indexOf(this.renderRoot.activeElement);
let target = null;
if (e.key === 'ArrowDown') {
target = items[(i + 1) % n];
} else if (e.key === 'ArrowUp') {
target = items[i <= 0 ? n - 1 : i - 1];
} else if (e.key === 'Home') {
target = items[0];
} else if (e.key === 'End') {
target = items[n - 1];
} else if (e.key.length === 1 && e.key !== ' ' && !e.ctrlKey && !e.metaKey && !e.altKey) {
// Type-ahead: the next item whose title starts with the letter.
const letter = e.key.toLowerCase();
target = [...items.slice(i + 1), ...items.slice(0, i + 1)].find(item =>
item.querySelector('.ide-tab-menu-title')?.textContent?.toLowerCase().startsWith(letter));
} else if (e.key !== 'Escape') {
return;
}|
@jorge-ferreira-pii The code that's been written to keep track of tabs that are overflowing is extremely complicated. IMO it's not worth the extra code to track such things. We should just put a constant ▼ button on every pan to allow users to click it, and remove the dynamic nature of the fading gradient. That should remove a large amount of code in the grid.js file |
| const inside = ['.ide-tab-menu', '.ide-btn-overflow'].some( | ||
| sel => path.includes(this.renderRoot.querySelector(sel))); | ||
| if (!inside) this._closeMenu(); |
There was a problem hiding this comment.
In lit and other reactive libraries you shouldn't use css selectors to store state. All state should be tracked by reactive elements, and then in the render you should apply the css labels you want.
This removes the need for you to track two sets of state inside your app.
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
…flow Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com> # Conflicts: # src/web/dist/app.min.js # src/web/dist/report.min.js
Thanks, I did in the latest commit:
One note: in the bottom pane, the new ▼ sits next to the console's collapse ▼; their tooltips differ ("List all tabs" / "Collapse Console"). Happy to change either icon if you prefer. |
…flow Signed-off-by: Matt Liberty <mliberty@precisioninno.com> # Conflicts: # src/web/src/timing-widget.js # src/web/test/js/test-timing-widget.js
Signed-off-by: Matt Liberty <mliberty@precisioninno.com> # Conflicts: # src/web/src/schematic-widget.js # src/web/src/timing-widget.js # src/web/test/js/test-timing-widget.js
…Back Double-click expansion and Back changed the view without updating the instance Refresh redraws, so Refresh jumped back to an older cone. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Splitting the pin name at its last '/' read a 3DBlox chiplet port (chip/port) as a pin of instance 'chip', so Cone synced the schematic to an instance that does not exist. The report already sends each node's instance. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
When the tab strip overflows and is scrolled to its end, the right-edge fade covered the last tab's close button; end padding lets it scroll clear. A pane with every tab closed opened an empty tab menu, so its button is disabled until a tab opens. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
|
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
7b7a975
into
The-OpenROAD-Project:master
Fixes #11892.
When a panel has more tabs than it can show, the hidden ones (Charts, for example) could only be reached by enlarging the panel, which hid the design.