Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat(paste): enhance accessibility with aria-labels and improve error handling

Aswin Asok9674d5880e8e
diff --git a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
index d41556d99e..62675c8a69 100644
--- a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
+++ b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
@@ -66,7 +66,10 @@ export const PasteCreatePanel = ({
fullWidth
slotProps={{
input: { disableUnderline: true },
- htmlInput: { maxLength: MAX_PASTE_CHARS },
+ htmlInput: {
+ maxLength: MAX_PASTE_CHARS,
+ "aria-label": "Paste text",
+ },
}}
multiline
minRows={5}
diff --git a/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx b/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx
index 0d12eb8fab..8fc396ab98 100644
--- a/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx
+++ b/web/apps/paste/src/features/paste/components/PasteLinkCard.tsx
@@ -168,7 +168,9 @@ export const PasteLinkCard = ({
});
return () => {
- animations.forEach((anim) => anim.cancel());
+ animations.forEach((anim) => {
+ anim.cancel();
+ });
};
}, [arrow]);
diff --git a/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx b/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
index 486b9484a9..8e43b4e197 100644
--- a/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
+++ b/web/apps/paste/src/features/paste/components/PasteViewPanel.tsx
@@ -151,6 +151,7 @@ export const PasteViewPanel = ({
minRows={10}
value={resolvedText}
slotProps={{
+ htmlInput: { "aria-label": "Paste contents" },
input: {
readOnly: true,
disableUnderline: true,
@@ -220,7 +221,9 @@ export const PasteViewPanel = ({
size="small"
disableElevation
onClick={() => {
- void onCopyText(resolvedText);
+ void onCopyText(resolvedText).catch(() => {
+ // Ignore errors to avoid unhandled rejections in click handlers.
+ });
}}
startIcon={
<ContentCopyRoundedIcon
diff --git a/web/apps/paste/src/features/paste/utils/browser.ts b/web/apps/paste/src/features/paste/utils/browser.ts
index 04932b3bd6..f26759e130 100644
--- a/web/apps/paste/src/features/paste/utils/browser.ts
+++ b/web/apps/paste/src/features/paste/utils/browser.ts
@@ -30,7 +30,10 @@ export const shareUrlOrCopy = async (url: string) => {
try {
await share.call(navigator, { url });
- } catch {
- // no-op on user cancellation
+ } catch (error) {
+ if (error instanceof DOMException && error.name === "AbortError") {
+ return;
+ }
+ await copyTextToClipboard(url);
}
};
diff --git a/web/apps/paste/src/features/paste/utils/lottie.ts b/web/apps/paste/src/features/paste/utils/lottie.ts
index 1bb2f562f6..e5c519faad 100644
--- a/web/apps/paste/src/features/paste/utils/lottie.ts
+++ b/web/apps/paste/src/features/paste/utils/lottie.ts
@@ -173,9 +173,8 @@ export const parseArrowLottie = (lottie: unknown): ParsedArrow | null => {
? toNumberArray(toNestedRecord(ks, "p")?.k)
: undefined;
- const sx = (toNumber(scaleValues?.[0], 100) || 100) / 100;
- const sy =
- (toNumber(scaleValues?.[1], scaleValues?.[0] ?? 100) || 100) / 100;
+ const sx = toNumber(scaleValues?.[0], 100) / 100;
+ const sy = toNumber(scaleValues?.[1], scaleValues?.[0] ?? 100) / 100;
const px = toNumber(positionValues?.[0], 0) || 0;
const py = toNumber(positionValues?.[1], 0) || 0;
diff --git a/web/apps/paste/src/features/paste/utils/qrcodegen.ts b/web/apps/paste/src/features/paste/utils/qrcodegen.ts
index 3182762f6f..3fe2e1ac38 100644
--- a/web/apps/paste/src/features/paste/utils/qrcodegen.ts
+++ b/web/apps/paste/src/features/paste/utils/qrcodegen.ts
@@ -166,10 +166,9 @@ namespace qrcodegen {
// Pack bits into bytes in big endian
let dataCodewords: Array<byte> = [];
while (dataCodewords.length * 8 < bb.length) dataCodewords.push(0);
- bb.forEach(
- (b: bit, i: int) =>
- (dataCodewords[i >>> 3] |= b << (7 - (i & 7))),
- );
+ bb.forEach((b: bit, i: int) => {
+ dataCodewords[i >>> 3] |= b << (7 - (i & 7));
+ });
// Create the QR Code object
return new QrCode(version, ecl, dataCodewords, mask);
@@ -706,10 +705,9 @@ namespace qrcodegen {
// Polynomial division
const factor: byte = b ^ (result.shift() as byte);
result.push(0);
- divisor.forEach(
- (coef, i) =>
- (result[i] ^= QrCode.reedSolomonMultiply(coef, factor)),
- );
+ divisor.forEach((coef, i) => {
+ result[i] ^= QrCode.reedSolomonMultiply(coef, factor);
+ });
}
return result;
}