[pull] main from tldraw:main#567
Merged
Merged
Conversation
In order to stop callers from hanging forever when a debounced function
is cancelled mid-flight, this PR makes `debounce(...).cancel()` reject
the pending promise with `Error('Debounced function was cancelled')`.
Follow-up to a review note on #8604, where `cancel()` was updated to
release captured arguments but the pending promise was still left
unsettled.
Previously, `cancel()` cleared the pending timeout but never resolved or
rejected the in-flight promise — so any code that did `await
debouncedFn(...)` and then called `.cancel()` (or had it called
externally, e.g. via a hook cleanup) would hang forever. To avoid
breaking the common fire-and-forget pattern (`useZoomCss`,
`Editor.deepLink`, search debouncers, bookmark debouncer, VS Code change
responder, etc.), an internal no-op `.catch` is attached so callers that
discard the promise don't trigger unhandled-rejection warnings.
Consumers that `await` or chain `.then` / `.catch` on the returned
promise still observe the rejection through their own chain.
### Change type
- [x] `bugfix`
### Test plan
- [x] Unit tests
New tests cover:
- `cancel()` rejects all pending callers from the same debounce window
with the expected error.
- A fresh call after `cancel()` gets a brand-new promise (and verifies
state is reset cleanly).
- `cancel()` is a no-op when nothing is pending; double-cancel is safe.
- No `unhandledRejection` event fires when callers discard the promise
and call `cancel()` (verifies the fire-and-forget pattern is
unaffected).
### Release notes
- Fixed `debounce(...).cancel()` leaving any in-flight promise
unsettled. Calling `cancel()` while a debounced call is pending now
rejects the returned promise with `Error('Debounced function was
cancelled')`. Code that `await`s a debounced call across a cancel should
wrap it in `try/catch`.
### Code changes
| Section | LOC change |
| --------- | ---------- |
| Core code | +21 / -3 |
| Tests | +62 / -0 |
Made with [Cursor](https://cursor.com)
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… note (#8958) In order to make list editing in note shapes behave like text and geo shape labels, this PR stops `Tab` from creating a new adjacent note when the caret is inside a bullet or ordered list. Closes #8713. Previously the note's keydown handler always created a new note on `Tab`, while the rich text editor's own keymap *also* indented the list item on the original note. This produced two bugs: an unwanted new note was created and focused, and the original note's list item was silently indented. Now, when a bullet or ordered list is active, the handler bails out early and lets the rich text editor indent the list item. ### Change type - [x] `bugfix` ### Test plan 1. Create a note shape and start editing it. 2. Open the rich text toolbar and turn on a bullet list (or ordered list). 3. Type some text, press `Enter` to start a second item, then press `Tab`. 4. Confirm the second item is indented under the first and no new note is created. 5. With no list active, confirm `Tab` still creates an adjacent note as before. ### Release notes - Fixed a bug where pressing `Tab` while editing a list inside a note shape created a new note instead of indenting the list item.
Fixing the app example page for custom colors: the example did not take reloading into account and when a shape is created with a custom style unfortunately it crashes the app because we don't persist the new additions to palette and fonts ### Change type - [x] `bugfix` - [ ] `improvement` - [ ] `feature` - [ ] `api` - [ ] `other` ### Test plan 1. go to example `/color-picker` 2. add a colour in the palette and some fonts 3. create a shape with new colour and font 4. reload - [ ] Unit tests - [ ] End to end tests ### Release notes - Fixed a bug in color-picker example that occurs when reloading the canvas without persisting the added styles Co-authored-by: Guillaume <guillaume@tldraw.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )