Fix layout shift in search bar by grouping results (Issue #34650)

This commit is contained in:
Uzair-Ahmed-Shah 2025-12-03 23:55:25 +05:30
parent 266577f48d
commit e984bc90c9
2 changed files with 21 additions and 9 deletions

View file

@ -587,7 +587,9 @@ describe('components/SwitchChannelProvider', () => {
];
expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({
terms: expectedOrder,
groups: [expect.objectContaining({
terms: expectedOrder,
})],
}));
});
@ -670,7 +672,9 @@ describe('components/SwitchChannelProvider', () => {
];
expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({
terms: expectedOrder,
groups: [expect.objectContaining({
terms: expectedOrder,
})],
}));
});
@ -757,7 +761,9 @@ describe('components/SwitchChannelProvider', () => {
'channel_other_user1',
];
expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({
terms: expectedOrder,
groups: [expect.objectContaining({
terms: expectedOrder,
})],
}));
});
@ -992,7 +998,9 @@ describe('components/SwitchChannelProvider', () => {
];
expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({
terms: expectedOrder,
groups: [expect.objectContaining({
terms: expectedOrder,
})],
}));
});

View file

@ -574,7 +574,7 @@ export default class SwitchChannelProvider extends Provider {
private initialFilteredList(channelPrefix: string, {items, terms}: {items: WrappedChannel[]; terms: string[]}): ProviderResults<WrappedChannel> {
let groups;
if (items) {
if (items && items.length > 0) {
groups = [{
key: 'channels',
label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}),
@ -585,7 +585,7 @@ export default class SwitchChannelProvider extends Provider {
} else {
groups = [{
key: 'moreChannels',
label: defineMessage({id: 'suggestion.mention.morechannels', defaultMessage: 'Other Channels'}),
label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}),
items: [{type: '', loading: true}],
terms: [''],
component: ConnectedSwitchChannelSuggestion,
@ -654,9 +654,13 @@ export default class SwitchChannelProvider extends Provider {
resultsCallback({
matchedPretext: channelPrefix,
items: combinedItems,
terms: combinedTerms,
component: ConnectedSwitchChannelSuggestion,
groups: [{
key: 'channels',
label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}),
items: combinedItems,
terms: combinedTerms,
component: ConnectedSwitchChannelSuggestion,
}],
});
}