0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-22 02:31:20 +01:00

11 Commits

Author SHA1 Message Date
Micah Kepe
03424ea997
Merge 0cabec3cfa409ea67ff73063d11d87ff9dee61fb into 87f729190918e957b1d80c5e94c4e3ff440a387c 2026-02-20 23:41:50 +08:00
silverwind
1b874d1403
Use first commit title for multi-commit PRs and fix auto-focus title field (#36606)
Fixes: https://github.com/go-gitea/gitea/issues/34865

1. When opening a PR from a branch with multiple commits, use the first
(oldest) commit's title as the default title instead of the branch name
2. Fix autofocus on PR title input field

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-02-17 09:06:27 +01:00
Micah Kepe
0cabec3cfa refactor(shortcuts): decouple keyboard shortcut mechanism into generic kbd handler
Move data-global-keyboard-shortcut from <input> to <kbd> elements so the
shortcut hint itself declares the shortcut key. The generic handler in
observer.ts now manages everything: focusing the sibling input on shortcut
key press, toggling kbd visibility on focus/blur, and clearing+blurring
on Escape.

This removes the element-specific initRepoCodeSearchShortcut function and
Vue v-show logic in favor of a fully decoupled approach. Any input can now
gain keyboard shortcut support by placing a sibling
<kbd data-global-keyboard-shortcut="key"> element.

Adds a devtest page at /devtest/keyboard-shortcut for manual testing.
2026-02-14 22:43:52 -08:00
micahkepe
a5480131b5 fix(shortcut): Address PR review feedback
- Use `target.isContentEditable` instead of `[contenteditable="true"]` selector
  to properly detect all contenteditable elements
- Use `CSS.escape()` for keyboard shortcut key to handle special characters
- Rename scoped CSS class to `.repo-file-search-shortcut-hint` to avoid
  conflict with global `.repo-search-shortcut-hint` styles
2026-02-14 22:43:52 -08:00
micahkepe
663612cdab refactor(shortcut): Use declarative data attributes for keyboard shortcuts
Instead of having JavaScript code guess which elements exist on a page,
elements now declare their keyboard shortcuts via data-global-keyboard-shortcut
attribute. This makes it easier to add new shortcuts and follows Gitea's
existing patterns for data-global-init and data-global-click.
2026-02-14 22:43:52 -08:00
silverwind
46d7adefe0
Enable TypeScript strictNullChecks (#35843)
A big step towards enabling strict mode in Typescript.

There was definitely a good share of potential bugs while refactoring
this. When in doubt, I opted to keep the potentially broken behaviour.
Notably, the `DOMEvent` type is gone, it was broken and we're better of
with type assertions on `e.target`.

---------

Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-03 02:13:16 +00:00
silverwind
8c8eb4b6f9
Clean up npm dependencies (#35484)
- `type-fest` is replaced by our own types
- `@stylistic/eslint-plugin-js` is no longer in use, it was replaced
with `@stylistic/eslint-plugin`
- `@types/license-checker-webpack-plugin` does not apply to our forked
version and has a type stub
2025-09-15 16:34:54 +02:00
wxiaoguang
d28a7f9fea
Fix dropdown delegating and some UI problems (#34014)
The old logic is incomplete. See the comment for the improved logic.

Fix #34011

And more fixes:

1. use empty "alt" for images, otherwise the width is not right when the
image fails to load
2. remove the "dropdown icon" patch, because it has been clearly done in
"dropdown.js" now
3. remove the "dropdown filtered item" patch, added a clear callback,
and improve the logic
4. fix global init when a node is removed and added back gain (eg: the
"cherry pick" dialog with a dropdown)
2025-03-26 02:51:22 +00:00
Kerwin Bryant
f0f1737d4d
Refactor markup and pdf-viewer to use new init framework (#33772)
1. Add some "render-content" classes to "markup" elements when the
content is rendered
2. Use correct "markup" wrapper for "preview" (but not set that class on
the tab)
3. Remove incorrect "markup" class from LFS file view, because there is
no markup content
    * "edit-diff" is also removed because it does nothing
5. Use "initPdfViewer" for PDF viewer
6. Remove incorrect "content" class from milestone markup
7. Init all ".markup" elements by new init framework

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-03 11:49:15 -08:00
wxiaoguang
27bf63ad20
Refactor global init code and add more comments (#33755)
Follow up #33748

Now there are 3 "global" functions:

* registerGlobalSelectorFunc: for all elements matching the selector, eg: `.ui.dropdown`
* registerGlobalInitFunc: for `data-global-init="initInputAutoFocusEnd"`
* registerGlobalEventFunc: for `data-global-click="onCommentReactionButtonClick"`


And introduce `initGlobalInput` to replace old `initAutoFocusEnd` and
`attachDirAuto`, use `data-global-init` to replace fragile
`.js-autofocus-end` selector.

Another benefit is that by the new approach, no matter how many times
`registerGlobalInitFunc` is called, we only need to do one
"querySelectorAll" in the last step, it could slightly improve the
performance.
2025-03-03 10:57:28 +08:00
wxiaoguang
698ae7aa5b
Fix dynamic content loading init problem (#33748)
1. Rewrite `dirauto.ts` to `observer.ts`. 
* We have been using MutationObserver for long time, it's proven that it
is quite performant.
    * Now we extend its ability to handle more "init" works.
2. Use `observeAddedElement` to init all non-custom "dropdown".
3. Use `data-global-click` to handle click events from dynamically
loaded elements.
* By this new approach, the old fragile selector-based
(`.comment-reaction-button`) mechanism is removed.
4. By the way, remove unused `.diff-box` selector, it was abused and
never really used.

A lot of FIXMEs in "repo-diff.ts" are completely fixed, newly loaded
contents could work as expected.
2025-03-01 02:02:10 +00:00