-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Desktop: Accessibility: Improve "change application layout" screen keyboard accessibility #11718
Merged
personalizedrefrigerator
merged 19 commits into
laurent22:dev
from
personalizedrefrigerator:pr/desktop/improve-change-app-layout-screen
Jan 27, 2025
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fa99c6d
Desktop: Accessibility: Fix missing button labels in "change app layout"
personalizedrefrigerator b9d69a5
Types
personalizedrefrigerator 00a19de
Show move controls in a dialog
personalizedrefrigerator 15c51f4
Fix move mode header styles
personalizedrefrigerator 54b7ce6
Add accessible labels to the move buttons (describe what they move)
personalizedrefrigerator 44306d0
Improve move button label styling
personalizedrefrigerator 92c4127
Fix button loses focus after clicking
personalizedrefrigerator 12d8430
Fix refocus when a button becomes disabled after clicking
personalizedrefrigerator 1c2c758
Make styles closer to the originals
personalizedrefrigerator b2c553c
Attempting to announce the position of the moved item
personalizedrefrigerator 550fa20
Revert attempt to announce position of the just-moved menu
personalizedrefrigerator c215796
Refactoring: Stronger types
personalizedrefrigerator a5e64a4
Refactoring: Convert function -> component
personalizedrefrigerator 4180890
Refactoring, scan resize screen in integration tests
personalizedrefrigerator 677f4c3
Fix unique key error
personalizedrefrigerator 2f0bc12
Use group role rather than manually adding aria-describedby, add test
personalizedrefrigerator 72e054c
Fix reset layout dialog is shown behind the app layout change screen
personalizedrefrigerator 87dd767
Code formatting
personalizedrefrigerator 6003790
Improve comment
personalizedrefrigerator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -43,6 +43,7 @@ import UpdateNotification from './UpdateNotification/UpdateNotification'; | |||||
import NoteEditor from './NoteEditor/NoteEditor'; | ||||||
import PluginNotification from './PluginNotification/PluginNotification'; | ||||||
import { Toast } from '@joplin/lib/services/plugins/api/types'; | ||||||
import PluginService from '@joplin/lib/services/plugins/PluginService'; | ||||||
|
||||||
const ipcRenderer = require('electron').ipcRenderer; | ||||||
|
||||||
|
@@ -121,6 +122,18 @@ const defaultLayout: LayoutItem = { | |||||
], | ||||||
}; | ||||||
|
||||||
const layoutKeyToLabel = (key: string, plugins: PluginStates) => { | ||||||
if (key === 'sideBar') return _('Sidebar'); | ||||||
if (key === 'noteList') return _('Note list'); | ||||||
if (key === 'editor') return _('Editor'); | ||||||
|
||||||
const viewInfo = pluginUtils.viewInfoByViewId(plugins, key); | ||||||
if (viewInfo) { | ||||||
return PluginService.instance().safePluginNameById(viewInfo.plugin.id); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The above is currently used to label panels from plugins. The "safe" in "safePluginNameById" was intended to mean that the method doesn't |
||||||
} | ||||||
return key; | ||||||
}; | ||||||
|
||||||
class MainScreenComponent extends React.Component<Props, State> { | ||||||
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied | ||||||
|
@@ -728,6 +741,10 @@ class MainScreenComponent extends React.Component<Props, State> { | |||||
); | ||||||
} | ||||||
|
||||||
private layoutKeyToLabel = (key: string) => { | ||||||
return layoutKeyToLabel(key, this.props.plugins); | ||||||
}; | ||||||
|
||||||
public render() { | ||||||
const theme = themeStyle(this.props.themeId); | ||||||
const style = { | ||||||
|
@@ -746,6 +763,7 @@ class MainScreenComponent extends React.Component<Props, State> { | |||||
onResize={this.resizableLayout_resize} | ||||||
onMoveButtonClick={this.resizableLayout_moveButtonClick} | ||||||
renderItem={this.resizableLayout_renderItem} | ||||||
layoutKeyToLabel={this.layoutKeyToLabel} | ||||||
moveMode={this.props.layoutMoveMode} | ||||||
moveModeMessage={_('Use the arrows to move the layout items. Press "Escape" to exit.')} | ||||||
/> | ||||||
|
69 changes: 69 additions & 0 deletions
69
packages/app-desktop/gui/ResizableLayout/LayoutItemContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as React from 'react'; | ||
import { Resizable, ResizeCallback, ResizeStartCallback, Size } from 're-resizable'; | ||
import { LayoutItem } from './utils/types'; | ||
import { itemMinHeight, itemMinWidth, itemSize, LayoutItemSizes } from './utils/useLayoutItemSizes'; | ||
|
||
interface Props { | ||
item: LayoutItem; | ||
parent: LayoutItem|null; | ||
sizes: LayoutItemSizes; | ||
resizedItemMaxSize: Size|null; | ||
onResizeStart: ResizeStartCallback; | ||
onResize: ResizeCallback; | ||
onResizeStop: ResizeCallback; | ||
children: React.ReactNode; | ||
isLastChild: boolean; | ||
visible: boolean; | ||
} | ||
|
||
const LayoutItemContainer: React.FC<Props> = ({ | ||
item, visible, parent, sizes, resizedItemMaxSize, onResize, onResizeStart, onResizeStop, children, isLastChild, | ||
}) => { | ||
const style: React.CSSProperties = { | ||
display: visible ? 'flex' : 'none', | ||
flexDirection: item.direction, | ||
}; | ||
|
||
const size: Size = itemSize(item, parent, sizes, true); | ||
|
||
const className = `resizableLayoutItem rli-${item.key}`; | ||
if (item.resizableRight || item.resizableBottom) { | ||
const enable = { | ||
top: false, | ||
right: !!item.resizableRight && !isLastChild, | ||
bottom: !!item.resizableBottom && !isLastChild, | ||
left: false, | ||
topRight: false, | ||
bottomRight: false, | ||
bottomLeft: false, | ||
topLeft: false, | ||
}; | ||
|
||
return ( | ||
<Resizable | ||
key={item.key} | ||
className={className} | ||
style={style} | ||
size={size} | ||
onResizeStart={onResizeStart} | ||
onResize={onResize} | ||
onResizeStop={onResizeStop} | ||
enable={enable} | ||
minWidth={'minWidth' in item ? item.minWidth : itemMinWidth} | ||
minHeight={'minHeight' in item ? item.minHeight : itemMinHeight} | ||
maxWidth={resizedItemMaxSize?.width} | ||
maxHeight={resizedItemMaxSize?.height} | ||
> | ||
{children} | ||
</Resizable> | ||
); | ||
} else { | ||
return ( | ||
<div key={item.key} className={className} style={{ ...style, ...size }}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default LayoutItemContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes to the
Button
component are to pass unused props through to the<button>
component it wraps. This removes the need to enumerate allaria-*
props that can be used with custom<Button>
s.