mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-28 07:37:36 +09:00
## Description 1. improved composeEventHandlers implementation 2. delete value text, then hit backspace - same as reset 3. in advanced panel all property tooltips now show "Delete property" wording instead of "Reset value" <img width="363" alt="image" src="https://github.com/user-attachments/assets/f4ad7ec4-892c-4774-9143-ac2b26c55cde" /> ## Steps for reproduction 1. click button 4. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
21 lines
527 B
TypeScript
21 lines
527 B
TypeScript
/*
|
|
* Inspired by
|
|
* https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx
|
|
*/
|
|
export const composeEventHandlers = <CustomEvent>(
|
|
handlers: Array<(event: CustomEvent) => void>,
|
|
{ checkForDefaultPrevented = true } = {}
|
|
) => {
|
|
return function handleEvent(event: CustomEvent) {
|
|
for (const handler of handlers) {
|
|
handler?.(event);
|
|
if (
|
|
checkForDefaultPrevented &&
|
|
(event as unknown as Event).defaultPrevented
|
|
) {
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
};
|