Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/pr-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Enterprise-Grade Modal Refactor: Security, Accessibility & Performance

## Summary

This PR refactors the modal implementation to improve **security**, **accessibility**, and **performance** while maintaining full backward compatibility with the existing `SocialShareButton` API.

## Changes

### Security

* Removed all `innerHTML` usage.
* Replaced string-based DOM generation with native DOM APIs (`createElement`, `createElementNS`, `textContent`).
* Added `DocumentFragment` for secure and efficient DOM construction.
* Improved compatibility with Trusted Types and strict Content Security Policy (CSP).

### Accessibility

* Added `role="dialog"`, `aria-modal="true"`, and `aria-labelledby`.
* Implemented keyboard focus trapping within the modal.
* Restored focus to the triggering element when the modal closes.
* Preserved Escape key support for closing the modal.
* Improved keyboard navigation in line with WCAG 2.1 AA recommendations.

### Performance

* Replaced multiple platform-specific event listeners with a single delegated event listener.
* Reduced memory usage by eliminating unnecessary listeners.
* Optimized DOM rendering using `DocumentFragment`.

## Testing

* Verified the Share modal opens and closes correctly.
* Verified all sharing platforms continue to function as expected.
* Tested keyboard navigation, focus trapping, and focus restoration.
* Confirmed Escape key closes the modal.
* Verified no visual or API regressions.

## Backward Compatibility

* No breaking API changes.
* Existing styling and functionality remain unchanged.
* Fully backward compatible with previous implementations.

This refactor improves the library's security, accessibility, maintainability, and runtime efficiency while preserving its existing behavior.
99 changes: 0 additions & 99 deletions landing-page/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions landing-page/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -10,17 +14,28 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
"@/*": [
"./src/*"
]
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading
Loading