Desktop: Fixes #10060: Fix "New note" button rendering when startup with Trash can selected.
Summary
Previously, New note button ref is stored by useRef, which doesn't trigger rerender when ref change. This cause if the Trash can is selected in previous session, when reopen the app, the ref to New note is null by default, preventing the New note button to re-render into correct format. More details and how to reproduce bugs: #10060.
Solution notes
- Changed useRef to useState instead for storing New note button element.
- I think panel width unchanged should not prevent re-render. There might be cases where element change needs re-render but panel width doesn't change (toggle button visibility for example).
So i remove this line
Testing
- Open Joplin, create an empty notebook in root
- Click on Trash can (make sure the New note button is hidden, Trash can is collapsed)
- Shrink the panel with search bar as small as possible.
- Close & reopen Joplin
- Click on the notebook in step 1, New note button should appear in correct format for small screen (which is an icon).
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
I forgot to mention, I'm participating GSoC 2024. This is my introduction: https://discourse.joplinapp.org/t/introduction-duy-huynh/36448
Looks good now, thanks @khuongduy354 for looking into this!