Bug/v2/all tools section headers gap (#4275)

# Description of Changes

<img width="701" height="574" alt="Screenshot 2025-08-24 at 2 42 22 PM"
src="https://github.com/user-attachments/assets/a5b74eca-176d-4e34-b1da-c5d024a04896"
/>

to: 

<img width="731" height="542" alt="Screenshot 2025-08-24 at 2 42 41 PM"
src="https://github.com/user-attachments/assets/4e6b0632-5581-4e20-ba62-81ba2fafcb4a"
/>


---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
EthanHealy01 2025-08-25 15:46:44 +01:00 committed by GitHub
parent e6f4cfb318
commit 55ebf9ebd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 20 deletions

View File

@ -54,21 +54,22 @@ const QuickAccessBar = forwardRef<HTMLDivElement>(({
handleReaderToggle(); handleReaderToggle();
} }
}, },
{ // TODO: Add sign tool
id: 'sign', // {
name: t("quickAccess.sign", "Sign"), // id: 'sign',
icon: // name: t("quickAccess.sign", "Sign"),
<span className="material-symbols-rounded font-size-20"> // icon:
signature // <span className="material-symbols-rounded font-size-20">
</span>, // signature
size: 'lg', // </span>,
isRound: false, // size: 'lg',
type: 'navigation', // isRound: false,
onClick: () => { // type: 'navigation',
setActiveButton('sign'); // onClick: () => {
handleToolSelect('sign'); // setActiveButton('sign');
} // handleToolSelect('sign');
}, // }
// },
{ {
id: 'automate', id: 'automate',
name: t("quickAccess.automate", "Automate"), name: t("quickAccess.automate", "Automate"),

View File

@ -25,19 +25,39 @@ const ToolPicker = ({ selectedToolKey, onSelect, filteredTools, isSearching = fa
const quickAccessRef = useRef<HTMLDivElement>(null); const quickAccessRef = useRef<HTMLDivElement>(null);
const allToolsRef = useRef<HTMLDivElement>(null); const allToolsRef = useRef<HTMLDivElement>(null);
// On resize adjust headers height to offset height // Keep header heights in sync with any dynamic size changes
useLayoutEffect(() => { useLayoutEffect(() => {
const update = () => { const update = () => {
if (quickHeaderRef.current) { if (quickHeaderRef.current) {
setQuickHeaderHeight(quickHeaderRef.current.offsetHeight); setQuickHeaderHeight(quickHeaderRef.current.offsetHeight || 0);
} }
if (allHeaderRef.current) { if (allHeaderRef.current) {
setAllHeaderHeight(allHeaderRef.current.offsetHeight); setAllHeaderHeight(allHeaderRef.current.offsetHeight || 0);
} }
}; };
update(); update();
// Update on window resize
window.addEventListener("resize", update); window.addEventListener("resize", update);
return () => window.removeEventListener("resize", update);
// Update on element resize (e.g., font load, badge count change, zoom)
const observers: ResizeObserver[] = [];
if (typeof ResizeObserver !== "undefined") {
const observe = (el: HTMLDivElement | null, cb: () => void) => {
if (!el) return;
const ro = new ResizeObserver(() => cb());
ro.observe(el);
observers.push(ro);
};
observe(quickHeaderRef.current, update);
observe(allHeaderRef.current, update);
}
return () => {
window.removeEventListener("resize", update);
observers.forEach(o => o.disconnect());
};
}, []); }, []);
const { sections: visibleSections } = useToolSections(filteredTools); const { sections: visibleSections } = useToolSections(filteredTools);
@ -152,7 +172,7 @@ const ToolPicker = ({ selectedToolKey, onSelect, filteredTools, isSearching = fa
ref={allHeaderRef} ref={allHeaderRef}
style={{ style={{
position: "sticky", position: "sticky",
top: quickSection ? quickHeaderHeight - 1: 0, top: quickSection ? quickHeaderHeight -1 : 0,
zIndex: 2, zIndex: 2,
borderTop: `0.0625rem solid var(--tool-header-border)`, borderTop: `0.0625rem solid var(--tool-header-border)`,
borderBottom: `0.0625rem solid var(--tool-header-border)`, borderBottom: `0.0625rem solid var(--tool-header-border)`,