Skip to content

Commit e0566e7

Browse files
authored
fix: Next Steps bubble spacing in Windows + visibility bug (#1719)
* fix: Next Steps bubble spacing in Windows + visibility bug * feat: Add dismissing next steps cards to mock-transport * fix: removal fn * fix: dismiss fn to remove from array
1 parent c4fbb4d commit e0566e7

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

special-pages/pages/new-tab/app/mock-transport.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export function mockTransport() {
9292
/** @type {Map<SubscriptionNames, any[]>} */
9393
const rmfSubscriptions = new Map();
9494
const freemiumPIRBannerSubscriptions = new Map();
95+
const nextStepsSubscriptions = new Map();
9596

9697
function clearRmf() {
9798
const listeners = rmfSubscriptions.get('rmf_onDataUpdate') || [];
@@ -102,6 +103,16 @@ export function mockTransport() {
102103
}
103104
}
104105

106+
function clearNextStepsCard(cardId, data) {
107+
const listeners = nextStepsSubscriptions.get('nextSteps_onDataUpdate') || [];
108+
const newContent = data.content.filter((card) => card.id !== cardId);
109+
const message = { content: newContent };
110+
for (const listener of listeners) {
111+
listener(message);
112+
write('nextSteps_data', message);
113+
}
114+
}
115+
105116
const transports = {
106117
customizer: customizerMockTransport(),
107118
activity: activityMockTransport(),
@@ -137,6 +148,7 @@ export function mockTransport() {
137148
}
138149
case 'rmf_dismiss': {
139150
console.log('ignoring rmf_dismiss', msg.params);
151+
clearRmf();
140152
return;
141153
}
142154
case 'freemiumPIRBanner_action': {
@@ -177,6 +189,15 @@ export function mockTransport() {
177189
console.log('mock: ignoring favorites_add');
178190
return;
179191
}
192+
case 'nextSteps_dismiss': {
193+
if (msg.params.id) {
194+
const data = read('nextSteps_data');
195+
clearNextStepsCard(msg.params.id, data);
196+
return;
197+
}
198+
console.log('ignoring nextSteps_dismiss');
199+
return;
200+
}
180201
default: {
181202
console.warn('unhandled notification', msg);
182203
}
@@ -231,6 +252,19 @@ export function mockTransport() {
231252
}
232253
return () => {};
233254
}
255+
case 'nextSteps_onDataUpdate': {
256+
const prev = nextStepsSubscriptions.get('nextSteps_onDataUpdate') || [];
257+
const next = [...prev];
258+
next.push(cb);
259+
nextStepsSubscriptions.set('nextSteps_onDataUpdate', next);
260+
const params = url.searchParams.get('next-steps');
261+
if (params && params in nextSteps) {
262+
const data = read('nextSteps_data');
263+
cb(data);
264+
}
265+
266+
return () => {};
267+
}
234268
case 'rmf_onDataUpdate': {
235269
// store the callback for later (eg: dismiss)
236270
const prev = rmfSubscriptions.get('rmf_onDataUpdate') || [];
@@ -387,6 +421,7 @@ export function mockTransport() {
387421
return { id: /** @type {any} */ (id) };
388422
}),
389423
};
424+
write('nextSteps_data', data);
390425
}
391426
return Promise.resolve(data);
392427
}

special-pages/pages/new-tab/app/next-steps/components/NextSteps.module.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@
186186
display: flex;
187187
align-items: center;
188188
justify-content: center;
189+
padding: 0 1px;
190+
margin: 0 -1px;
189191

190192
h2 {
191193
color: var(--ntp-text-on-primary);

special-pages/pages/new-tab/app/next-steps/components/NextStepsGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function NextStepsCardGroup({ types, expansion, toggle, action, dismiss }
3131

3232
return (
3333
<div class={styles.cardGroup} id={WIDGET_ID}>
34-
<NextStepsBubbleHeader />
34+
{types.length > 0 && <NextStepsBubbleHeader />}
3535
<div class={styles.cardGrid}>
3636
{alwaysShown.map((type) => (
3737
<NextStepsCard key={type} type={type} dismiss={dismiss} action={action} />

0 commit comments

Comments
 (0)