Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add <overflow-menu>, rename webcomponents #29400

Merged
merged 86 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
8a8c625
WIP: Overflow menu
silverwind Feb 25, 2024
ba13360
fix calc
silverwind Feb 25, 2024
9cc21fe
progress
silverwind Feb 26, 2024
2a439ca
progress
silverwind Feb 26, 2024
c73d3ab
error handler stuff
silverwind Feb 26, 2024
049c6cf
const
silverwind Feb 26, 2024
708aad3
dot
silverwind Feb 26, 2024
c258536
progress
silverwind Feb 26, 2024
c945b61
revert bootstrap changes
silverwind Feb 26, 2024
93bcd09
more progress
silverwind Feb 26, 2024
ef7ecf7
rename variable
silverwind Feb 26, 2024
8c6acd9
rename another variable
silverwind Feb 26, 2024
9b261ea
Merge branch 'main' into overflow-menu
silverwind Mar 2, 2024
f1463f7
prevent layout shift when active element hides
silverwind Mar 2, 2024
eb90267
move it to a web component
silverwind Mar 2, 2024
2d404d0
rename to 'overflow-menu' and use it everywhere
silverwind Mar 2, 2024
ae228bc
rename 'gitea-origin-url' to 'origin-url', misc tweaks
silverwind Mar 2, 2024
886f105
fix justify on centered menus
silverwind Mar 2, 2024
16e7ffb
update tippy after creation
silverwind Mar 2, 2024
26a7d01
remove now-unnecessary class removal
silverwind Mar 2, 2024
73b2cb3
destroy tippy when removing button
silverwind Mar 2, 2024
1843a96
remove dead css
silverwind Mar 2, 2024
44b8019
rename variable and class
silverwind Mar 2, 2024
878f7e6
typo
silverwind Mar 2, 2024
ab70cb1
fix lint-templates
silverwind Mar 2, 2024
682ae3a
remove default background and add it via tailwind on login pages
silverwind Mar 3, 2024
8045ca3
use it on org page
silverwind Mar 3, 2024
f769241
use it on user page
silverwind Mar 3, 2024
27c94c0
hide sooner
silverwind Mar 3, 2024
b14e132
replace requestAnimationFrame with MutationObserver
silverwind Mar 3, 2024
8ab94ed
Merge branch 'main' into overflow-menu
silverwind Mar 3, 2024
6182d5f
add vue compat for custom elements, styling tweaks
silverwind Mar 3, 2024
6aa9f88
move observer disconnect
silverwind Mar 3, 2024
8a64b70
prevent fouc with defer in webcomponents script
silverwind Mar 3, 2024
e145a5d
split webcomponents into two scripts to avoid all FOUCs
silverwind Mar 3, 2024
07cea89
move back to one webcomponents file, remove getBoundingClientRect
silverwind Mar 3, 2024
2cf34a3
fix the fouc
silverwind Mar 3, 2024
551f910
avoid one querySelector
silverwind Mar 3, 2024
f74a491
avoid another querySelector, tweak comments
silverwind Mar 3, 2024
562543d
remove cloneNode
silverwind Mar 3, 2024
5dfe109
remove last querySelector
silverwind Mar 3, 2024
90a53b1
typo
silverwind Mar 3, 2024
d67b19d
Update .eslintrc.yaml
silverwind Mar 3, 2024
1830851
remove unneeded class
silverwind Mar 3, 2024
22e4e07
tweak comment
silverwind Mar 3, 2024
23e716f
Merge branch 'main' into overflow-menu
GiteaBot Mar 3, 2024
2d0ec1b
remove obsolete file
silverwind Mar 3, 2024
f37213a
use it in DashboardRepoList
silverwind Mar 3, 2024
77a8e1e
use requestAnimationFrame to avoid warning, add disconnects
silverwind Mar 3, 2024
6e93db1
Merge branch 'main' into overflow-menu
silverwind Mar 4, 2024
f13f8e0
use wc- prefix
silverwind Mar 4, 2024
b4583a9
add files, docs and enhance isCustomElement
silverwind Mar 4, 2024
ba8a47b
Update web_src/js/webcomponents/wc-overflow-menu.js
silverwind Mar 5, 2024
8718035
revert to unprefixed
silverwind Mar 6, 2024
de5074c
Merge remote-tracking branch 'origin/main' into overflow-menu
silverwind Mar 6, 2024
9fe309a
fix filenames
silverwind Mar 6, 2024
fe950b9
remove fomantic menu dependency
silverwind Mar 6, 2024
0ede830
remove from code-line-menu as well
silverwind Mar 6, 2024
f586358
add some aria
silverwind Mar 6, 2024
d7c0b01
set aria-haspopup on all tippy with click trigger
silverwind Mar 6, 2024
fc193c2
css tweaks
silverwind Mar 6, 2024
5df5e44
re-enable eslint rule
silverwind Mar 6, 2024
98b3523
add link
silverwind Mar 6, 2024
b37df74
move guide
silverwind Mar 6, 2024
680b032
remove unneeded polyfill, available in palemoon now
silverwind Mar 6, 2024
d524b24
de-intend via early exit button removal
silverwind Mar 6, 2024
22f71f6
Merge branch 'main' into overflow-menu
silverwind Mar 9, 2024
e168714
Merge branch 'main' into overflow-menu
silverwind Mar 12, 2024
40bfc8b
add padding
silverwind Mar 12, 2024
98893a4
use 'More items'
silverwind Mar 12, 2024
cd77433
tippy fixes, add missing box-shadow
silverwind Mar 12, 2024
b3703f8
add navigation role
silverwind Mar 12, 2024
84a7d6b
fix incorrect aria attribute
wxiaoguang Mar 13, 2024
9c2fdb9
add basic aria support
wxiaoguang Mar 13, 2024
b1e4857
Merge branch 'main' into overflow-menu
silverwind Mar 13, 2024
0532acb
rename to gitea-absolute-date to absolute-date
silverwind Mar 13, 2024
1b8f7ff
add absolute-date to vue config
silverwind Mar 13, 2024
9f9fbee
fix lint
silverwind Mar 13, 2024
19d55ec
add arrow key handling, move focus to target element initially
silverwind Mar 13, 2024
cbf3fc1
fix unfocusable vue links
silverwind Mar 13, 2024
ee51556
Merge branch 'main' into overflow-menu
silverwind Mar 13, 2024
05df5b6
add comment
silverwind Mar 13, 2024
a753af5
Merge branch 'main' into overflow-menu
silverwind Mar 14, 2024
7130333
Merge branch 'main' into overflow-menu
silverwind Mar 14, 2024
97ed9ed
move prevent/stop into conditionals
silverwind Mar 14, 2024
1f87f8f
Merge branch 'main' into overflow-menu
GiteaBot Mar 15, 2024
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
4 changes: 4 additions & 0 deletions web_src/css/modules/tippy.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
background: var(--color-hover);
}

.tippy-box[data-theme="menu"] .item:focus {
background: var(--color-active);
}

/* box-with-header theme to look like .ui.attached.segment. can contain .ui.attached.header */

.tippy-box[data-theme="box-with-header"] {
Expand Down
35 changes: 27 additions & 8 deletions web_src/js/webcomponents/overflow-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
if (!this.tippyContent) {
const div = document.createElement('div');
div.classList.add('tippy-target');
div.tabIndex = '-1';
div.addEventListener('keydown', (e) => {
if (e.code === 'Tab') {
if (e.key === 'Tab') {
const items = this.tippyContent.querySelectorAll('[role="menuitem"]');
if (e.shiftKey) {
if (document.activeElement === items[0]) {
Expand All @@ -22,18 +23,34 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
items[0].focus();
}
}
} else if (e.code === 'Escape') {
} else if (e.key === 'Escape') {
e.preventDefault();
e.stopPropagation();
this.button._tippy.hide();
this.button.focus();
} else if (e.code === 'Space') {
// eslint-disable-next-line unicorn/no-lonely-if
if (document.activeElement.matches('[role="menuitem"]')) {
e.preventDefault();
} else if (e.key === ' ' || e.code === 'Enter') {
e.preventDefault();
e.stopPropagation();
silverwind marked this conversation as resolved.
Show resolved Hide resolved
if (document.activeElement?.matches('[role="menuitem"]')) {
document.activeElement.click();
}
} else if (e.key === 'ArrowDown') {
e.preventDefault();
e.stopPropagation();
if (document.activeElement?.matches('.tippy-target')) {
document.activeElement.querySelector('[role="menuitem"]').focus();
} else if (document.activeElement?.matches('[role="menuitem"]')) {
document.activeElement.nextElementSibling?.focus();
}
} else if (e.key === 'ArrowUp') {
e.preventDefault();
e.stopPropagation();
silverwind marked this conversation as resolved.
Show resolved Hide resolved
if (document.activeElement?.matches('.tippy-target')) {
document.activeElement.querySelector('[role="menuitem"]:last-of-type').focus();
} else if (document.activeElement?.matches('[role="menuitem"]')) {
document.activeElement.previousElementSibling?.focus();
}
}
// TODO: handle arrow keys (at the moment, tab&shift-tab also work)
});
this.append(div);
this.tippyContent = div;
Expand Down Expand Up @@ -98,7 +115,9 @@ window.customElements.define('overflow-menu', class extends HTMLElement {
role: 'menu',
content: this.tippyContent,
onShow: () => { // FIXME: onShown doesn't work (never be called)
setTimeout(() => this.tippyContent.querySelector('[role="menuitem"]').focus());
setTimeout(() => {
this.tippyContent.focus();
}, 0);
},
});
});
Expand Down
Loading