Skip to content

Commit 3c51e2a

Browse files
update demo
1 parent db057a1 commit 3c51e2a

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

docs/data/joy/components/autocomplete/AutocompleteHint.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ const StyledDiv = styled('div')({
1515
function Wrapper({ children, hint, ...props }) {
1616
return (
1717
<StyledDiv {...props}>
18-
<Typography sx={{ position: 'absolute', opacity: 0.6 }}>{hint}</Typography>
18+
<Typography
19+
sx={{
20+
position: 'absolute',
21+
opacity: 0.6,
22+
overflow: 'hidden', // Hide overflow
23+
whiteSpace: 'nowrap', // Prevent text wrapping
24+
maxWidth: '100%', // Ensure the hint doesn't exceed container width
25+
}}
26+
>
27+
{hint}
28+
</Typography>
1929
{children}
2030
</StyledDiv>
2131
);
@@ -53,7 +63,7 @@ export default function AutocompleteHint() {
5363
}
5464
}
5565
}}
56-
onBlur={() => {
66+
onClose={() => {
5767
hint.current = '';
5868
}}
5969
inputValue={inputValue}

docs/data/joy/components/autocomplete/AutocompleteHint.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ type WrapperProps = {
1919
function Wrapper({ children, hint, ...props }: WrapperProps) {
2020
return (
2121
<StyledDiv {...props}>
22-
<Typography sx={{ position: 'absolute', opacity: 0.6 }}>{hint}</Typography>
22+
<Typography
23+
sx={{
24+
position: 'absolute',
25+
opacity: 0.6,
26+
overflow: 'hidden', // Hide overflow
27+
whiteSpace: 'nowrap', // Prevent text wrapping
28+
maxWidth: '100%', // Ensure the hint doesn't exceed container width
29+
}}
30+
>
31+
{hint}
32+
</Typography>
2333
{children}
2434
</StyledDiv>
2535
);
@@ -52,7 +62,7 @@ export default function AutocompleteHint() {
5262
}
5363
}
5464
}}
55-
onBlur={() => {
65+
onClose={() => {
5666
hint.current = '';
5767
}}
5868
inputValue={inputValue}

docs/data/material/components/autocomplete/AutocompleteHint.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ export default function AutocompleteHint() {
1616
}
1717
}
1818
}}
19-
onBlur={() => {
19+
onClose={() => {
2020
hint.current = '';
2121
}}
2222
onChange={(event, newValue) => {
2323
setInputValue(newValue && newValue.label ? newValue.label : '');
2424
}}
2525
disablePortal
2626
inputValue={inputValue}
27-
blurOnSelect
2827
id="combo-box-hint-demo"
2928
options={top100Films}
3029
sx={{ width: 300 }}

docs/data/material/components/autocomplete/AutocompleteHint.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ export default function AutocompleteHint() {
1616
}
1717
}
1818
}}
19-
onBlur={() => {
19+
onClose={() => {
2020
hint.current = '';
2121
}}
2222
onChange={(event, newValue) => {
2323
setInputValue(newValue && newValue.label ? newValue.label : '');
2424
}}
2525
disablePortal
2626
inputValue={inputValue}
27-
blurOnSelect
2827
id="combo-box-hint-demo"
2928
options={top100Films}
3029
sx={{ width: 300 }}

0 commit comments

Comments
 (0)