Skip to content

Commit a1aa0ab

Browse files
TkDodopriscilawebdev
authored andcommitted
fix(ui2): disclosure hover (#102206)
in UI2, only use the hover effects of the transparent button instead of styling the surrounding container. No changes in UI2, only UI2: | before | after | |--------|--------| | <img width="454" height="85" alt="Screenshot 2025-10-28 at 13 28 19" src="https://github.com/user-attachments/assets/d34482bb-ad8e-4be6-abe0-ca41d6bd65c7" /> | <img width="466" height="91" alt="Screenshot 2025-10-28 at 13 28 43" src="https://github.com/user-attachments/assets/2cf558fc-9435-4a21-a05e-ac4dcbd8e261" /> | | <img width="463" height="86" alt="Screenshot 2025-10-28 at 13 28 36" src="https://github.com/user-attachments/assets/4571a5cb-f197-487b-ad55-73da83afed93" /> | <img width="460" height="81" alt="Screenshot 2025-10-28 at 13 28 12" src="https://github.com/user-attachments/assets/a84c6794-a816-4761-aff3-873e567814a7" /> |
1 parent 3ddfc4e commit a1aa0ab

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

static/app/components/core/disclosure/disclosure.mdx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,13 @@ function LocalStorageDisclosure() {
191191

192192
Disclosures can maintain their expanded state across page reloads by using URL state.
193193

194+
import {parseAsBoolean, useQueryState} from 'nuqs';
195+
194196
export function URLStateDisclosure() {
195-
const [expanded, setExpanded] = useState(new URLSearchParams(window.location.search).get('my-disclosure-key') === 'true');
197+
const [expanded, setExpanded] = useQueryState('my-disclosure-key', parseAsBoolean.withDefault(false));
196198

197199
return (
198-
<Disclosure defaultExpanded={expanded} onExpandedChange={(expanded) => {
199-
const url = new URL(window.location.href);
200-
url.searchParams.set('my-disclosure-key', expanded ? 'true' : 'false');
201-
window.history.pushState({}, '', url.toString());
202-
setExpanded(expanded);
203-
}}>
200+
<Disclosure defaultExpanded={expanded} onExpandedChange={setExpanded}>
204201
<Disclosure.Title>The expanded state is saved to URL state</Disclosure.Title>
205202
<Disclosure.Content>Reload the page to see the expanded state is remembered and new params are added to the URL</Disclosure.Content>
206203
</Disclosure>
@@ -215,21 +212,16 @@ export function URLStateDisclosure() {
215212
</Storybook.Demo>
216213

217214
```tsx
215+
import {parseAsBoolean, useQueryState} from 'nuqs';
216+
218217
function URLStateDisclosure() {
219-
const [expanded, setExpanded] = useState<boolean>(
220-
new URLSearchParams(window.location.search).get('my-disclosure-key') === 'true'
218+
const [expanded, setExpanded] = useQueryState(
219+
'my-disclosure-key',
220+
parseAsBoolean.withDefault(false)
221221
);
222222

223223
return (
224-
<Disclosure
225-
defaultExpanded={expanded}
226-
onExpandedChange={expanded => {
227-
const url = new URL(window.location.href);
228-
url.searchParams.set('my-disclosure-key', expanded ? 'true' : 'false');
229-
window.history.pushState({}, '', url.toString());
230-
setExpanded(expanded);
231-
}}
232-
>
224+
<Disclosure defaultExpanded={expanded} onExpandedChange={setExpanded}>
233225
<Disclosure.Title>The expanded state is saved to URL state</Disclosure.Title>
234226
<Disclosure.Content>
235227
Reload the page to see the expanded state is remembered

static/app/components/core/disclosure/disclosure.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,21 @@ function Title({children, trailingItems, ...rest}: DisclosureTitleProps) {
111111
}
112112

113113
const HoverStyleFlex = styled(Flex)`
114-
&:hover {
115-
background-color: ${p => p.theme.backgroundSecondary};
116-
}
114+
${p =>
115+
p.theme.isChonk
116+
? ''
117+
: css`
118+
&:hover {
119+
background-color: ${p.theme.backgroundSecondary};
120+
}
121+
`}
117122
`;
118123

119124
const StretchedButton = styled(Button)`
120125
flex-grow: 1;
121126
justify-content: flex-start;
122127
padding-left: ${p => p.theme.space.xs};
123128
124-
&:hover {
125-
background-color: transparent;
126-
}
127-
128129
${p =>
129130
p.theme.isChonk
130131
? ''

0 commit comments

Comments
 (0)