Skip to content

Commit 7a3486f

Browse files
committed
BUGFIX: Show loading state in results view
1 parent 8ee005b commit 7a3486f

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Resources/Private/Translations/de/Main.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<source>Try a different query to find more results</source>
5151
<target>Versuchen sie eine andere Eingabe, um mehr Ergebnisse zu finden.</target>
5252
</trans-unit>
53+
<trans-unit id="CommandResultsView.waitingForResults">
54+
<source>Waiting for results…</source>
55+
<target>Warten auf Ergebnisse…</target>
56+
</trans-unit>
5357
<trans-unit id="ToggleButton.label">
5458
<source>Search…</source>
5559
<target>Suche…</target>

Resources/Private/Translations/en/Main.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
<source>Try a different query to find more results</source>
4444
</trans-unit>
4545

46+
<trans-unit id="CommandResultsView.waitingForResults">
47+
<source>Waiting for results…</source>
48+
</trans-unit>
49+
4650
<trans-unit id="ToggleButton.label">
4751
<source>Search…</source>
4852
</trans-unit>

packages/commandbar/src/components/CommandResultsView/CommandResultsView.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import React from 'react';
22
import { useComputed, useSignalEffect } from '@preact/signals';
33

4-
import { useCommandBarState, useCommandExecutor } from '../../state';
4+
import { useCommandBarState, useCommandExecutor, useIntl } from '../../state';
55
import CommandListItem from '../CommandListItem/CommandListItem';
66

77
import * as styles from './CommandResultsView.module.css';
88

99
const CommandResultsView: React.FC = () => {
1010
const {
11-
state: { result, highlightedOption },
11+
state: { result, highlightedOption, activeCommandId },
1212
} = useCommandBarState();
1313
const { executeCommand } = useCommandExecutor();
14+
const { translate } = useIntl();
1415
const navRef = React.useRef<HTMLElement>(null);
1516
const highlightedId = useComputed<CommandId>(() =>
1617
result.value ? Object.values(result.value.options)[highlightedOption.value].id : null
1718
);
19+
const isLoading = activeCommandId.value !== null;
1820

1921
useSignalEffect(() => {
2022
const highlightedIndex = highlightedOption.value;
@@ -28,8 +30,9 @@ const CommandResultsView: React.FC = () => {
2830
return (
2931
<div className={styles.commandResultsView}>
3032
{message && <h6 className={styles.message}>{message}</h6>}
31-
{view ? <div>{view}</div> : ''}
32-
{options && (
33+
{isLoading ? <div>{translate('CommandResultsView.waitingForResults', 'Waiting for results…')}</div> : ''}
34+
{!isLoading && view ? <div>{view}</div> : ''}
35+
{!isLoading && options && (
3336
<nav className={styles.results} ref={navRef}>
3437
<ul>
3538
{Object.keys(options).map((commandId) => (

0 commit comments

Comments
 (0)