Skip to content

Commit d1a2b53

Browse files
committed
Fix a bug causing nav bar to float out of fixed position on iOS devices
1 parent dda8254 commit d1a2b53

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

example/src/components/Usage.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,31 @@ function SubmenuExample() {
113113

114114
function EventHandlingExample() {
115115
const ref = useRef(null);
116-
const [text, setText] = useState('');
116+
const lineNum = useRef(1);
117+
const [output, setOutput] = useState([]);
118+
119+
const addLine = line => {
120+
return setOutput(o => [...o, <li key={lineNum.current++}>{line}</li>]);
121+
}
117122

118123
const handleMenuClick = e => {
119-
setText(t => t + `[Menu] ${e.value} clicked\n\n`);
124+
addLine(`[Menu] ${e.value} clicked`);
125+
addLine('------');
120126
};
121127

122128
const handleFileClick = e => {
123-
setText(t => t + `[MenuItem] ${e.value} clicked\n`);
129+
addLine(`[MenuItem] ${e.value} clicked`);
124130
};
125131

126132
const handleSaveClick = e => {
127-
setText(t => t + `[MenuItem] ${e.value} clicked\n\n`);
133+
addLine(`[MenuItem] ${e.value} clicked`);
134+
addLine('------');
128135
return false;
129136
};
130137

131138
useLayoutEffect(() => {
132139
ref.current.scrollTop = ref.current.scrollHeight;
133-
}, [text]);
140+
}, [output]);
134141

135142
return (
136143
<Example data={codeExamples.eventHandling} >
@@ -150,12 +157,14 @@ function EventHandlingExample() {
150157
</Menu>
151158

152159
<button className="btn btn btn-dark"
153-
onClick={() => setText('')}>
160+
onClick={() => setOutput([])}>
154161
Clear
155162
</button>
156163
</div>
157164

158-
<textarea readOnly ref={ref} value={text} />
165+
<ul className="output" ref={ref}>
166+
{output}
167+
</ul>
159168
</Example>
160169
);
161170
}

example/src/data/codeExamples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ export const customisedButton = {
672672
own React button component which implements a forwarding ref and
673673
accepts <code>onClick</code> and <code>onKeyDown</code> event props.</p>
674674
<p><code>Menu</code> also works well with third-party React libraries,
675-
such as the Material-UI.
675+
such as the <b>Material-UI</b>.
676676
See <a href="https://codesandbox.io/s/react-menu-material-ui-example-wvzpc"
677677
target="_blank" rel="noopener noreferrer">
678678
an example on CodeSandbox</a>.</p>

example/src/styles/_example.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
[aria-labelledby="event-handling"] {
4040
.example__demo {
41-
min-height: 15rem;
41+
height: 15rem;
4242
align-items: stretch;
4343
justify-content: space-around;
4444

@@ -48,10 +48,14 @@
4848
justify-content: space-around;
4949
}
5050

51-
textarea {
51+
.output {
52+
@include mixins.reset-list;
5253
font-size: 0.9rem;
5354
flex: 0 1 20rem;
5455
margin-left: 1rem;
56+
border: 1px solid var.$border-color;
57+
border-radius: var.$border-radius-medium;
58+
overflow-y: auto;
5559
}
5660
}
5761
}

example/src/styles/index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ code {
6161
img {
6262
height: 2rem;
6363
object-fit: contain;
64+
&:hover {
65+
opacity: 0.7;
66+
}
6467
}
6568
}
6669

0 commit comments

Comments
 (0)