Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.5.6-beta02</Version>
<Version>9.5.6-beta03</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ export function init(id, invoke) {
if (duration > 0) {
ac.debounce = true
EventHandler.on(input, 'keydown', debounce(e => {
handlerKeydown(ac, e);
handlerKeydown(e);
}, duration, e => {
return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1
}))
}
else {
EventHandler.on(input, 'keydown', e => {
handlerKeydown(ac, e);
handlerKeydown(e);
})
}

EventHandler.on(input, 'keyup', e => handlerKeyup(ac, e));

ac.triggerBlur = () => {
el.classList.remove('show');
const triggerBlur = input.getAttribute('data-bb-blur') === 'true';
Expand Down Expand Up @@ -117,7 +119,7 @@ export function init(id, invoke) {
});
}

const handlerKeydown = (ac, e) => {
const handlerKeyup = (ac, e) => {
const key = e.key;
const { el, input, invoke, menu } = ac;
if (key === 'Enter' || key === 'NumpadEnter') {
Expand Down Expand Up @@ -162,6 +164,9 @@ const handlerKeydown = (ac, e) => {
invoke.invokeMethodAsync('TriggerDeleteCallback', input.value);
}
}
}

const handlerKeydown = e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Undefined reference to ac in handlerKeydown.

The keydown event handler now calls handlerKeydown(e), but this function uses 'ac' (e.g. in ac.triggerBlur()) without receiving it as a parameter. This is likely to result in an undefined reference. Consider passing 'ac' to handlerKeydown similarly to how it's done for the keyup handler or capturing it via a closure.

if (e.key === 'Tab') {
ac.triggerBlur();
}
Expand Down Expand Up @@ -193,6 +198,7 @@ export function dispose(id) {
}
EventHandler.off(input, 'change');
EventHandler.off(input, 'keydown');
EventHandler.off(input, 'keyup');
EventHandler.off(menu, 'click');
Input.dispose(input);

Expand Down